diff options
author | ankitjavalkar | 2018-07-05 17:46:00 +0530 |
---|---|---|
committer | ankitjavalkar | 2018-07-13 13:00:35 +0530 |
commit | 69a07a92309105b289f4d08957729bda68727bf2 (patch) | |
tree | 085e152ce20dc050f7144e4e958788c03f972184 /yaksh/models.py | |
parent | 26ca38c6243eaa1d94bca68481eb60b2276ab7b2 (diff) | |
download | online_test-69a07a92309105b289f4d08957729bda68727bf2.tar.gz online_test-69a07a92309105b289f4d08957729bda68727bf2.tar.bz2 online_test-69a07a92309105b289f4d08957729bda68727bf2.zip |
- Add buttons to Moderator and Student templates
- Modify _add_to_moderator function to _toggle_moderator_function in order to allow addition and removal of moderator group link
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 8 |
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()) |