From 80b658f5aa58313be5890e3d607b9537f461ea3b Mon Sep 17 00:00:00 2001 From: Alisson Date: Wed, 13 Mar 2013 01:28:53 -0300 Subject: [PATCH] Remove unnecessary if conditions if obj it None, it's None, there's no need to check it --- django/contrib/auth/models.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index df3851d353..5709d25d7f 100644 --- a/django/contrib/auth/models.py +++ b/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 @@ 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):