From 81a6cd0dc2bb3498eec2f003c5e19cc0fb096e81 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Mon, 21 Jan 2019 18:23:03 +0530 Subject: Remove user as teacher of any course if is_moderator is set to False --- yaksh/models.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'yaksh/models.py') 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: -- cgit