def post(self, request, *args, **kwargs): # remove all modules from list that were being watched obj = self.get_object() modules = list(obj.modules.all()) watcher = WatcherWrapper(obj.user) watcher.bulk_module_remove(*modules) return super(AdminReviewerDeleteView, self).post(request, *args, **kwargs)
def __process_watchers(self): """ Private method that removes the modules that are being watched by these tutor. """ obj = self.get_object() modules = obj.modules.all() # remove the modules from watch list watcher = WatcherWrapper(obj.programme_tutor_user) watcher.bulk_module_remove(*list(modules))
def __process_watchers(self, request): """ Private method to update the tutor's watch list by removing and adding relevant modules """ # get the list of new module codes module_codes = request.POST.getlist('modules', None) obj = self.get_object() watcher = WatcherWrapper(obj.programme_tutor_user) # get the current and new modules new_modules = set(Module.objects.filter(module_code__in=module_codes)) current_modules = set(obj.modules.all()) # determine what needs to be removed modules_to_remove = list(current_modules.difference(new_modules)) # update the modules this tutor is watching watcher.bulk_module_remove(*modules_to_remove) watcher.bulk_module_add(*list(new_modules))
def __process_watchers(self, request): """ Private method that updates notification watcher for a reviewer. """ # get the new list of module codes module_codes = request.POST.getlist('modules', None) obj = self.get_object() watcher = WatcherWrapper(obj.user) # get the new modules new_modules = set(Module.objects.filter(module_code__in=module_codes)) old_modules = set(obj.modules.all()) # compare the old modules to new to determine which # modules are no longer being reviewed by reviewer modules_to_remove = list(old_modules.difference(new_modules)) # remove modules that are not being reviewed by user watcher.bulk_module_remove(*modules_to_remove) # add any new modules that are being reviewed watcher.bulk_module_add(*list(new_modules))