Beispiel #1
0
 def test_search_assets_after_update(self):
     asset = assets_service.create_asset(self.project_id,
                                         self.asset_type_id, "Girafe", "",
                                         {})
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 1)
     assets_service.update_asset(asset["id"], {"name": "Elephant"})
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 0)
     assets = index_service.search_assets("elephant")
     self.assertEqual(len(assets), 1)
Beispiel #2
0
    def post_processing(self):
        # We handle the fact that an asset can have multiple parents by using
        # the entities out field as a children field.
        for key in self.parent_map.keys():
            try:
                asset = assets_service.get_asset_by_shotgun_id(key)
                data = {"entities_out": self.parent_map[key]}
                assets_service.update_asset(asset["id"], data)
            except AssetNotFoundException:
                pass

        return self.parent_map
Beispiel #3
0
    def post_processing(self):
        # We handle the fact that an asset can have multiple parents by using
        # the entities out field as a children field.
        for key in self.parent_map.keys():
            try:
                asset = assets_service.get_asset_by_shotgun_id(key)

                asset = assets_service.get_full_asset(asset['id'])
                former_children = [
                    Entity.get(child_id)
                    for child_id in asset.get('entities_out', [])
                ]
                children = list(set(self.parent_map[key] + former_children))
                data = {"entities_out": children}

                assets_service.update_asset(asset["id"], data)
                assets_service.clear_asset_cache(asset["id"])
            except AssetNotFoundException:
                pass

        return self.parent_map
Beispiel #4
0
def _run_status_automation(automation, task, person_id):
    is_automation_to_run = (
        task["task_type_id"] == automation["in_task_type_id"]
        and task["task_status_id"] == automation["in_task_status_id"])
    if not is_automation_to_run:
        return

    priorities = projects_service.get_task_type_priority_map(
        task["project_id"], automation["entity_type"].capitalize())
    in_priority = priorities.get(automation["in_task_type_id"], 0) or 0
    out_priority = priorities.get(automation["out_task_type_id"], 0) or 0
    is_rollback = (priorities is not None
                   and automation["out_field_type"] != "ready_for"
                   and in_priority > out_priority)
    if is_rollback:  # Do not apply rollback to avoid change cycles.
        return

    if automation["out_field_type"] == "status":
        tasks_to_update = tasks_service.get_tasks_for_entity_and_task_type(
            task["entity_id"], automation["out_task_type_id"])
        if len(tasks_to_update) > 0:
            task_to_update = tasks_to_update[0]
            task_type = tasks_service.get_task_type(
                automation["in_task_type_id"])
            task_status = tasks_service.get_task_status(
                automation["in_task_status_id"])
            create_comment(
                person_id,
                task_to_update["id"],
                automation["out_task_status_id"],
                "Change triggered by %s set to %s" % (
                    task_type["name"],
                    task_status["name"],
                ),
                [],
                {},
                None,
            )
    elif automation["out_field_type"] == "ready_for":
        try:
            asset = assets_service.update_asset(
                task["entity_id"],
                {"ready_for": automation["out_task_type_id"]},
            )
            breakdown_service.refresh_casting_stats(asset)
        except AssetNotFoundException:
            pass
Beispiel #5
0
 def test_update_asset(self):
     asset = self.asset.serialize(obj_type="Asset")
     asset = assets_service.update_asset(asset["id"], {"name": "New name"})
     asset_again = assets_service.get_asset(asset["id"])
     self.assertDictEqual(asset, asset_again)