Exemple #1
0
    def put(self, person_id):
        (task_ids) = self.get_arguments()

        if len(task_ids) > 0:
            task = tasks_service.get_task(task_ids[0])
            user_service.check_manager_project_access(task["project_id"])

        tasks = []
        for task_id in task_ids:
            try:
                task = self.assign_task(task_id, person_id)
                author = persons_service.get_current_user()
                notifications_service.create_assignation_notification(
                    task_id, person_id, author["id"]
                )
                tasks.append(task)
            except TaskNotFoundException:
                pass
            except PersonNotFoundException:
                return {"error": "Assignee doesn't exist in database."}, 400

        if len(tasks) > 0:
            projects_service.add_team_member(tasks[0]["project_id"], person_id)

        return tasks
Exemple #2
0
 def test_create_assignation_notification(self):
     self.generate_fixture_comment()
     notifications_service.create_assignation_notification(
         self.task_dict["id"], self.person.id)
     notifications = Notification.get_all()
     self.assertEqual(len(notifications), 1)
     self.assertEqual(notifications[0].type, "assignation")
     self.assertEqual(str(notifications[0].author_id),
                      self.task_dict["assigner_id"])
Exemple #3
0
    def put(self, person_id):
        """
        Assign given task lists to given person.
        ---
        tags:
        - Tasks
        description: If a given task ID is wrong, it ignores it.
        parameters:
          - in: path
            name: person_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: body
            name: Task
            description: List of tasks ID
            schema:
                type: object
                required:
                  - task_ids
                properties:
                    task_ids:
                        type: UUID
                        example: a24a6ea4-ce75-4665-a070-57453082c25
        responses:
            200:
                description: Given tasks lists assigned to given person
        """
        (task_ids) = self.get_arguments()

        tasks = []
        current_user = persons_service.get_current_user()
        for task_id in task_ids:
            try:
                user_service.check_task_departement_access(task_id, person_id)
                task = self.assign_task(task_id, person_id, current_user["id"])
                author = persons_service.get_current_user()
                notifications_service.create_assignation_notification(
                    task_id, person_id, author["id"])
                tasks.append(task)
            except TaskNotFoundException:
                pass
            except permissions.PermissionDenied:
                pass
            except PersonNotFoundException:
                return {"error": "Assignee doesn't exist in database."}, 400
        if len(tasks) > 0:
            projects_service.add_team_member(tasks[0]["project_id"], person_id)

        return tasks
Exemple #4
0
    def put(self, task_id):
        (person_id) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_manager_project_access(task["project_id"])

            self.assign_task(task_id, person_id)
            notifications_service.create_assignation_notification(
                task_id, person_id)
            projects_service.add_team_member(task["project_id"], person_id)
        except PersonNotFoundException:
            return {"error": "Assignee doesn't exist in database."}, 400

        return task
Exemple #5
0
    def put(self, task_id):
        """
        Assign given task list to given person.
        ---
        tags:
        - Tasks
        parameters:
          - in: path
            name: task_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: body
            name: Person
            description: Person ID
            schema:
                type: object
                required:
                  - person_id
                properties:
                    person_id:
                        type: UUID
                        example: a24a6ea4-ce75-4665-a070-57453082c25
        responses:
            200:
                description: Given task assigned to given person
            400:
                description: Assignee non-existent in database
        """
        (person_id) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_manager_project_access(task["project_id"])

            self.assign_task(task_id, person_id)
            notifications_service.create_assignation_notification(
                task_id, person_id)
            projects_service.add_team_member(task["project_id"], person_id)
        except PersonNotFoundException:
            return {"error": "Assignee doesn't exist in database."}, 400

        return task