Skip to content

Commit cb4ae03

Browse files
author
Matthew Fisher
committed
style(controller): flatter if statements, DRF updates
1 parent 14bdbcc commit cb4ae03

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

controller/api/views.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ def list(self, request, **kwargs):
323323
app = get_object_or_404(self.model, id=kwargs['id'])
324324
perm_name = "api.{}".format(self.perm)
325325
if request.user != app.owner and \
326-
not request.user.has_perm(perm_name, app) and \
327-
not request.user.is_superuser:
326+
not request.user.has_perm(perm_name, app) and \
327+
not request.user.is_superuser:
328328
return Response(status=status.HTTP_403_FORBIDDEN)
329329
usernames = [u.username for u in get_users_with_perms(app)
330330
if u.has_perm(perm_name, app)]
@@ -344,20 +344,19 @@ def destroy(self, request, **kwargs):
344344
if request.user != app.owner and not request.user.is_superuser:
345345
return Response(status=status.HTTP_403_FORBIDDEN)
346346
user = get_object_or_404(User, username=kwargs['username'])
347-
if user.has_perm(self.perm, app):
348-
remove_perm(self.perm, user, app)
349-
models.log_event(app, "User {} was revoked access to {}".format(user, app))
350-
return Response(status=status.HTTP_204_NO_CONTENT)
351-
else:
347+
if not user.has_perm(self.perm, app):
352348
return Response(status=status.HTTP_403_FORBIDDEN)
349+
remove_perm(self.perm, user, app)
350+
models.log_event(app, "User {} was revoked access to {}".format(user, app))
351+
return Response(status=status.HTTP_204_NO_CONTENT)
353352

354353

355354
class AdminPermsViewSet(BaseDeisViewSet):
356355
"""RESTful views for sharing admin permissions with other users."""
357356

358357
model = User
359358
serializer_class = serializers.AdminUserSerializer
360-
permission_classes = (permissions.IsAdmin,)
359+
permission_classes = [permissions.IsAdmin]
361360

362361
def get_queryset(self, **kwargs):
363362
self.check_object_permissions(self.request, self.request.user)

0 commit comments

Comments
 (0)