aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2013-08-21 17:07:59 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2013-08-21 17:07:59 +0300
commitc741f1738786c58253b400ffc27a16967702f84c (patch)
tree6eaf1433754bc1c1b7f633b3f3aa791d4530613e
parent8e599abd2aa1af210992f97f8dea5727e18a1928 (diff)
downloaddjango-crowd-rest-backend-c741f1738786c58253b400ffc27a16967702f84c.tar.gz
Do staff/superuser flag manipulation only if correspodning optiosn are set.HEADmaster
I.e. if AUTH_CROWD_SUPERUSER_GROUP and/or AUTH_CROWD_STAFF_GROUP are unset, don't touch these flags, otherwise we get unexpected resets of flags.
-rw-r--r--crowdrest/backend.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/crowdrest/backend.py b/crowdrest/backend.py
index 6b3a3b3..c0900d6 100644
--- a/crowdrest/backend.py
+++ b/crowdrest/backend.py
@@ -116,14 +116,18 @@ class CrowdRestBackend(object):
group_names = [group_map.get(x, x) for x in group_names]
group_names = set(group_names)
- if getattr(settings, "AUTH_CROWD_SUPERUSER_GROUP", None) in group_names:
- user.is_superuser = True
- else:
- user.is_superuser = False
- if getattr(settings, "AUTH_CROWD_STAFF_GROUP", None) in group_names:
- user.is_staff = True
- else:
- user.is_staff = False
+ su_group = getattr(settings, "AUTH_CROWD_SUPERUSER_GROUP", None)
+ if su_group:
+ if su_group in group_names:
+ user.is_superuser = True
+ else:
+ user.is_superuser = False
+ staff_group = getattr(settings, "AUTH_CROWD_STAFF_GROUP", None)
+ if staff_group:
+ if staff_group in group_names:
+ user.is_staff = True
+ else:
+ user.is_staff = False
if getattr(settings, "AUTH_CROWD_CREATE_GROUPS", False):
group_objs = [Group.objects.get_or_create(name=g)[0] for g in group_names]