summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorankitjavalkar2018-07-13 12:58:57 +0530
committerankitjavalkar2018-07-13 13:01:43 +0530
commit0af47ee9292132ab472e3e0bbae617d77437ff72 (patch)
treea5c8a3ab617107743864f9faacad341d0e74da00 /yaksh/models.py
parent9e209521aa81631d940c3ca2010a9f373e4af09c (diff)
downloadonline_test-0af47ee9292132ab472e3e0bbae617d77437ff72.tar.gz
online_test-0af47ee9292132ab472e3e0bbae617d77437ff72.tar.bz2
online_test-0af47ee9292132ab472e3e0bbae617d77437ff72.zip
Fix bug that changes moderator-student view on every profile save
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 7e0fbb2..152289f 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1026,7 +1026,10 @@ class Profile(models.Model):
self.user.groups.remove(group)
def save(self, *args, **kwargs):
- self._toggle_moderator_group(group_name=MOD_GROUP_NAME)
+ if self.pk is not None:
+ old_profile = Profile.objects.get(pk=self.pk)
+ if old_profile.is_moderator != self.is_moderator:
+ self._toggle_moderator_group(group_name=MOD_GROUP_NAME)
super(Profile, self).save(*args, **kwargs)
def __str__(self):