summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorankitjavalkar2019-01-21 18:23:03 +0530
committerankitjavalkar2019-01-21 19:20:15 +0530
commit81a6cd0dc2bb3498eec2f003c5e19cc0fb096e81 (patch)
tree00e0acfb6d788cd3cb5caa1e4785e3b4f55a60af /yaksh/models.py
parent310d3813f58d292b54e42fb43f4554cbe5c944ce (diff)
downloadonline_test-81a6cd0dc2bb3498eec2f003c5e19cc0fb096e81.tar.gz
online_test-81a6cd0dc2bb3498eec2f003c5e19cc0fb096e81.tar.bz2
online_test-81a6cd0dc2bb3498eec2f003c5e19cc0fb096e81.zip
Remove user as teacher of any course if is_moderator is set to False
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 480a111..427b584 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1096,12 +1096,17 @@ class Profile(models.Model):
os.chmod(user_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
return user_dir
+ def get_moderated_courses(self):
+ return Course.objects.filter(teachers=self.user)
+
def _toggle_moderator_group(self, group_name):
group = Group.objects.get(name=group_name)
if self.is_moderator:
self.user.groups.add(group)
else:
self.user.groups.remove(group)
+ for course in self.get_moderated_courses():
+ course.remove_teachers(self.user)
def save(self, *args, **kwargs):
if self.pk is not None: