diff options
author | ankitjavalkar | 2019-01-28 11:03:39 +0530 |
---|---|---|
committer | GitHub | 2019-01-28 11:03:39 +0530 |
commit | 53e43a65f0b47557da035597f37b4ee9a9d5e290 (patch) | |
tree | 32a6095973f3bc4f198942fd416da870847058d8 /yaksh/models.py | |
parent | 310d3813f58d292b54e42fb43f4554cbe5c944ce (diff) | |
parent | 7f91d11b37aaeb5a673f623d21ff2390983e0f8c (diff) | |
download | online_test-53e43a65f0b47557da035597f37b4ee9a9d5e290.tar.gz online_test-53e43a65f0b47557da035597f37b4ee9a9d5e290.tar.bz2 online_test-53e43a65f0b47557da035597f37b4ee9a9d5e290.zip |
Merge pull request #551 from ankitjavalkar/remove-mod-from-teacher
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.py | 5 |
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: |