Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove unnecessary if conditions

if obj it None, it's None, there's no need to check it
  • Loading branch information...
commit 80b658f5aa58313be5890e3d607b9537f461ea3b 1 parent 86aaff7
@sayadn sayadn authored apollo13 committed
Showing with 4 additions and 15 deletions.
  1. +4 −15 django/contrib/auth/models.py
View
19 django/contrib/auth/models.py
@@ -263,22 +263,15 @@ def _user_get_all_permissions(user, obj):
permissions = set()
for backend in auth.get_backends():
if hasattr(backend, "get_all_permissions"):
- if obj is not None:
- permissions.update(backend.get_all_permissions(user, obj))
- else:
- permissions.update(backend.get_all_permissions(user))
+ permissions.update(backend.get_all_permissions(user, obj))
return permissions
def _user_has_perm(user, perm, obj):
for backend in auth.get_backends():
if hasattr(backend, "has_perm"):
- if obj is not None:
- if backend.has_perm(user, perm, obj):
- return True
- else:
- if backend.has_perm(user, perm):
- return True
+ if backend.has_perm(user, perm, obj):
+ return True
return False
@@ -318,11 +311,7 @@ def get_group_permissions(self, obj=None):
permissions = set()
for backend in auth.get_backends():
if hasattr(backend, "get_group_permissions"):
- if obj is not None:
- permissions.update(backend.get_group_permissions(self,
- obj))
- else:
- permissions.update(backend.get_group_permissions(self))
+ permissions.update(backend.get_group_permissions(self, obj))
return permissions
def get_all_permissions(self, obj=None):
Please sign in to comment.
Something went wrong with that request. Please try again.