Format all python files using the formatter
Run `git ls-files '*.py' | xargs black`
Issue: HIC-161
Change-Id: I1619e6296bc4036504c5bb73128f769a1b7b688d
diff --git a/crashreports/permissions.py b/crashreports/permissions.py
index ff79149..c1efe79 100644
--- a/crashreports/permissions.py
+++ b/crashreports/permissions.py
@@ -7,42 +7,49 @@
device = Device.objects.get(user=user)
except:
return False
- if (uuid == device.uuid):
+ if uuid == device.uuid:
return True
return False
def user_is_hiccup_staff(user):
- if (user.groups.filter(name='FairphoneSoftwareTeam').exists()):
+ if user.groups.filter(name="FairphoneSoftwareTeam").exists():
return True
else:
- return user.has_perms([
- # Crashreports
- 'crashreports.add_crashreport', 'crashreports.change_crashreport',
- 'crashreports.del_crashreport',
- # Heartbeats
- 'heartbeat.add_crashreport', 'heartbeat.change_crashreport',
- 'heartbeat.del_crashreport',
- # Logfiles
- 'heartbeat.add_logfile', 'heartbeat.change_logfile',
- 'heartbeat.del_logfile',
- ])
+ return user.has_perms(
+ [
+ # Crashreports
+ "crashreports.add_crashreport",
+ "crashreports.change_crashreport",
+ "crashreports.del_crashreport",
+ # Heartbeats
+ "heartbeat.add_crashreport",
+ "heartbeat.change_crashreport",
+ "heartbeat.del_crashreport",
+ # Logfiles
+ "heartbeat.add_logfile",
+ "heartbeat.change_logfile",
+ "heartbeat.del_logfile",
+ ]
+ )
+
class HasStatsAccess(BasePermission):
def has_permission(self, request, view):
return user_is_hiccup_staff(request.user)
+
class HasRightsOrIsDeviceOwnerDeviceCreation(BasePermission):
def has_permission(self, request, view):
- if (user_is_hiccup_staff(request.user)):
+ if user_is_hiccup_staff(request.user):
return True
# special case:
# user is the owner of a device. in this case creations are allowed.
# we have to check if the device with the supplied uuid indeed
# belongs to the user
- if request.method == 'POST':
- if ('uuid' not in request.data):
+ if request.method == "POST":
+ if "uuid" not in request.data:
return False
return user_owns_uuid(request.user, request.data["uuid"])
return False