summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 1199a92..e9d4947 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1001,14 +1001,16 @@ class Profile(models.Model):
os.chmod(user_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
return user_dir
- def _add_to_moderator_group(self, group_name='moderator'):
+ def _toggle_moderator_group(self, group_name='moderator'):
+ group = Group.objects.get(name=group_name)
if self.is_moderator:
- group = Group.objects.get(name=group_name)
self.user.groups.add(group)
+ else:
+ self.user.groups.remove(group)
def save(self, *args, **kwargs):
+ self._toggle_moderator_group()
super(Profile, self).save(*args, **kwargs)
- self._add_to_moderator_group()
def __str__(self):
return '%s' % (self.user.get_full_name())