示例#1
0
 def post(self, task_type_id):
     permissions.check_manager_permissions()
     criterions = query.get_query_criterions_from_request(request)
     shots = shots_service.get_shots(criterions)
     task_type = tasks_service.get_task_type(task_type_id)
     tasks = [tasks_service.create_task(task_type, shot) for shot in shots]
     return tasks, 201
示例#2
0
    def create_and_update_tasks(self,
                                tasks_update,
                                entity,
                                asset_creation=False):
        if tasks_update:
            tasks_map = {}
            if asset_creation:
                task_type_ids = self.get_task_types_for_asset_type(
                    entity.entity_type_id)
                for task_type_id in task_type_ids:
                    task = tasks_service.create_task({"id": task_type_id},
                                                     entity.serialize())
                    tasks_map[task_type_id] = task
            else:
                for task in tasks_service.get_tasks_for_asset(str(entity.id)):
                    tasks_map[task["task_type_id"]] = task

            for task_update in tasks_update:
                if task_update["task_type_id"] not in tasks_map:
                    task = tasks_service.create_task(
                        tasks_service.get_task_type(
                            task_update["task_type_id"]),
                        entity.serialize(),
                    )
                    tasks_map[task_update["task_type_id"]] = task
                task = tasks_map[task_update["task_type_id"]]
                if (task_update["comment"] is not None
                        or task_update["task_status_id"] !=
                        task["task_status_id"]):
                    try:
                        comments_service.create_comment(
                            self.current_user_id,
                            task["id"],
                            task_update["task_status_id"]
                            or task["task_status_id"],
                            task_update["comment"] or "",
                            [],
                            {},
                            "",
                        )
                    except WrongParameterException:
                        pass
        elif asset_creation:
            self.created_assets.append(entity.serialize())
示例#3
0
 def test_create_task(self):
     shot = self.shot.serialize()
     task_type = self.task_type.serialize()
     status = tasks_service.get_todo_status()
     task = tasks_service.create_task(task_type, shot)
     task = tasks_service.get_task(task["id"])
     self.assertEquals(task["entity_id"], shot["id"])
     self.assertEquals(task["task_type_id"], task_type["id"])
     self.assertEquals(task["project_id"], shot["project_id"])
     self.assertEquals(task["task_status_id"], status["id"])
示例#4
0
    def post(self, task_type_id):
        criterions = query.get_query_criterions_from_request(request)
        if "project_id" not in criterions:
            return {"error": True, "message": "Project ID is missing"}, 400

        user_service.check_manager_project_access(criterions["project_id"])
        shots = shots_service.get_shots(criterions)
        task_type = tasks_service.get_task_type(task_type_id)
        tasks = [tasks_service.create_task(task_type, shot) for shot in shots]
        return tasks, 201
示例#5
0
文件: shots.py 项目: cgwire/zou
    def create_and_update_tasks(
        self, tasks_update, entity, shot_creation=False
    ):
        if tasks_update:
            if shot_creation:
                tasks_map = {
                    str(task_type.id): create_task(
                        task_type.serialize(), entity.serialize()
                    )
                    for task_type in self.task_types_in_project_for_shots
                }
            else:
                tasks_map = {
                    task["task_type_id"]: task
                    for task in get_tasks_for_shot(str(entity.id))
                }

            for task_update in tasks_update:
                if task_update["task_type_id"] not in tasks_map:
                    tasks_map[task_update["task_type_id"]] = create_task(
                        get_task_type(task_update["task_type_id"]),
                        entity.serialize(),
                    )
                task = tasks_map[task_update["task_type_id"]]
                if (
                    task_update["comment"] is not None
                    or task_update["task_status_id"] != task["task_status_id"]
                ):
                    try:
                        create_comment(
                            self.current_user_id,
                            task["id"],
                            task_update["task_status_id"]
                            or task["task_status_id"],
                            task_update["comment"] or "",
                            [],
                            {},
                            "",
                        )
                    except WrongParameterException:
                        pass
        elif shot_creation:
            self.created_shots.append(entity.serialize())