def __process_watchers(self):
        # add modules that the user needs to review
        # to thier notification watch list
        user = self.object.user

        # get all the modules
        modules = list(self.object.modules.all())
        watcher = WatcherWrapper(user)
        watcher.bulk_module_add(*modules)
    def __process_watchers(self):
        """
        Private method to add modules to tutor watch list
        """
        user = self.object.programme_tutor_user

        # get the modules
        modules = self.object.modules.all()

        # add the modules to user's watch list
        tutor_watcher = WatcherWrapper(user)
        tutor_watcher.bulk_module_add(*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))