Remove unnecessary if conditions

if obj it None, it's None, there's no need to check it
This commit is contained in:
Alisson 2013-03-13 01:28:53 -03:00 committed by Florian Apolloner
parent 86aaff75d0
commit 80b658f5aa
1 changed files with 4 additions and 15 deletions

View File

@ -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))
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
return False
@ -318,11 +311,7 @@ class PermissionsMixin(models.Model):
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):