Ejemplo n.º 1
0
 def delete(self, person_id, department_id):
     """
     Remove a user from given department.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: department_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         204:
             description: User removed from given department
     """
     permissions.check_admin_permissions()
     try:
         department = tasks_service.get_department(department_id)
     except DepartmentNotFoundException:
         raise WrongParameterException(
             "Department ID matches no department"
         )
     persons_service.remove_from_department(department_id, person_id)
     return "", 204
Ejemplo n.º 2
0
 def post(self, person_id):
     """
     Add a user to given department.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         201:
             description: User added to given department
     """
     permissions.check_admin_permissions()
     args = self.get_args(
         [
             ("department_id", None, True),
         ]
     )
     try:
         department = tasks_service.get_department(args["department_id"])
     except DepartmentNotFoundException:
         raise WrongParameterException(
             "Department ID matches no department"
         )
     person = persons_service.add_to_department(department["id"], person_id)
     return person, 201
Ejemplo n.º 3
0
 def delete(self, person_id, department_id):
     permissions.check_admin_permissions()
     try:
         department = tasks_service.get_department(department_id)
     except DepartmentNotFoundException:
         raise WrongParameterException("Department ID matches no department")
     persons_service.remove_from_department(department_id, person_id)
     return "", 204
Ejemplo n.º 4
0
 def post(self, person_id):
     permissions.check_admin_permissions()
     args = self.get_args([
         ("department_id", None, True),
     ])
     try:
         department = tasks_service.get_department(args["department_id"])
     except DepartmentNotFoundException:
         raise WrongParameterException("Department ID matches no department")
     person = persons_service.add_to_department(department["id"], person_id)
     return person, 201