Esempio n. 1
0
 def get(self, asset_id):
     """
     Retrieve all tasks related to a given shot.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return tasks_service.get_tasks_for_asset(asset_id)
Esempio n. 2
0
 def get(self, asset_id):
     """
     Retrieve all tasks related to a given shot.
     """
     asset = assets_service.get_asset(asset_id)
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(asset["project_id"])
     return tasks_service.get_tasks_for_asset(asset_id)
Esempio n. 3
0
 def delete_func(self, asset):
     try:
         asset = assets_service.get_asset_by_shotgun_id(asset.shotgun_id)
         tasks = tasks_service.get_tasks_for_asset(asset["id"])
         if self.is_working_files_linked(tasks):
             assets_service.cancel_asset(asset["id"])
         else:
             for task in tasks:
                 deletion_service.remove_task(task["id"])
             assets_service.remove_asset(asset["id"])
         return asset
     except AssetNotFoundException:
         return None
Esempio n. 4
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())
Esempio n. 5
0
 def get(self, asset_id):
     """
     Retrieve all tasks related to a given shot.
     ---
     tags:
         - Assets
     parameters:
       - in: path
         name: asset_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25       
     responses:
         200:
             description: All tasks related to given shot   
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return tasks_service.get_tasks_for_asset(asset_id)
Esempio n. 6
0
 def test_get_tasks_for_asset(self):
     tasks = tasks_service.get_tasks_for_asset(self.entity.id)
     self.assertEqual(len(tasks), 1)
     self.assertEqual(tasks[0]["id"], str(self.task.id))