From 66280a44c1f76ecb6900cbab02feda324eebb05b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 30 May 2012 11:07:59 +0200 Subject: [PATCH] sync django is_superuser status with level --- pandora/user/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora/user/models.py b/pandora/user/models.py index 8d1400a3..29459b5b 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -175,8 +175,20 @@ class UserProfile(models.Model): def set_level(self, level): self.level = settings.CONFIG['userLevels'].index(level) + if self.level == len(settings.CONFIG['userLevels']) - 1: + if not self.user.is_superuser: + self.user.is_superuser = True + self.user.save() + elif self.user.is_superuser: + self.user.is_superuser = False + self.user.save() def get_level(self): + #django superuser should always be admin + if self.user.is_superuser: + if self.level != len(settings.CONFIG['userLevels']) - 1: + self.level = len(settings.CONFIG['userLevels']) - 1 + self.save() return settings.CONFIG['userLevels'][self.level] def capability(self, capability):