Example #1
0
    def remove(self, objective_id, student_id, tutor_id, by_user):
        """Remove an objective from a users set of adopted objectives.

        :param objective_id: is the id of the `Objective` to be removed.
        :param student_id: is the id of the `User` for whom the `Objective` is being removed.
        :param tutor_id: is the id of the `User` who is removing the `Objective`.
        :param by_user: is the `User` who is calling the action.
        """

        remove_schema = {'id': s.Use(int),
                         'student_id': s.Use(int),
                         'tutor_id': s.Use(int)
        }
        s.Schema(remove_schema).validate({'id': objective_id,
                                              'student_id': student_id,
                                              'tutor_id': tutor_id})

        self._check_user_id_or_admin(tutor_id, by_user)
        UserObjective.ignore_or_delete(student_id, tutor_id, objective_id)