예제 #1
0
파일: resources.py 프로젝트: connectdtk/zou
 def get(self, asset_id):
     """
     Retrieve all scene asset instances linked to asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return breakdown_service.get_scene_asset_instances_for_asset(asset_id)
예제 #2
0
파일: resources.py 프로젝트: connectdtk/zou
 def get(self, asset_id):
     """
     Retrieve all task types related to a given asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return tasks_service.get_task_types_for_asset(asset_id)
예제 #3
0
파일: resources.py 프로젝트: cgwire/zou
 def post(self, asset_id):
     """
     Create an asset instance inside given asset.
     ---
     tags:
         - Assets
     parameters:
       - in: path
         name: asset_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25       
     responses:
         201:
             description: Asset instance created inside given asset    
     """
     args = self.get_args([
         ("asset_to_instantiate_id", None, True),
         ("description", None, False),
     ])
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     asset_instance = breakdown_service.add_asset_instance_to_asset(
         asset_id, args["asset_to_instantiate_id"], args["description"])
     return asset_instance, 201
예제 #4
0
파일: resources.py 프로젝트: maxdudik/zou
 def get(self, asset_id):
     """
     Retrieve all assets for a given shot.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return breakdown_service.get_entity_casting(asset_id)
예제 #5
0
    def test_get_asset(self):
        asset = assets_service.get_asset(self.entity.id)
        self.assertEqual(asset["id"], str(self.entity.id))

        assets_service.remove_asset(asset["id"])
        self.assertRaises(AssetNotFoundException, assets_service.get_asset,
                          self.entity.id)
예제 #6
0
 def check_read_permissions(self, instance):
     if permissions.has_manager_permissions():
         return True
     else:
         asset_instance = self.get_model_or_404(instance["id"])
         asset = assets_service.get_asset(asset_instance.id)
         return user_service.check_has_task_related(asset["project_id"])
예제 #7
0
파일: resources.py 프로젝트: connectdtk/zou
 def get(self, asset_id):
     """
     Resource to retrieve the casting of a given asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return breakdown_service.get_cast_in(asset_id)
예제 #8
0
    def test_set_main_preview(self):
        path = "/pictures/preview-files/%s" % self.preview_file_id

        file_path_fixture = self.get_fixture_file_path(
            os.path.join("thumbnails", "th01.png"))
        self.upload_file(path, file_path_fixture)

        path = ("/actions/preview-files/%s/set-main-preview" %
                self.preview_file_id)
        self.put(path, {})

        asset = assets_service.get_asset(self.asset_id)
        self.assertEqual(asset["preview_file_id"], str(self.preview_file_id))

        self.put(
            "/actions/entities/%s/set-main-preview/%s" %
            (self.preview_file_id, self.preview_file_id),
            {},
            404,
        )

        self.put(
            "/actions/entities/%s/set-main-preview/%s" %
            (self.asset_id, self.asset_id),
            {},
            404,
        )
        entity = Entity.get(self.asset_id)
        entity.preview_file_id = None
        entity.save()
예제 #9
0
파일: resources.py 프로젝트: NeroSouza/zou
    def post(self, asset_instance_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])
            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"]
                )
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                pass
            asset_instance = assets_service.get_asset_instance(
                asset_instance_id
            )

            entity = assets_service.get_asset(asset_instance["asset_id"])
            if not permissions.has_manager_permissions():
                user_service.check_has_task_related(entity["project_id"])

            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file = files_service.create_new_output_revision(
                asset_instance["asset_id"],
                working_file_id,
                output_type["id"],
                person["id"],
                task_type["id"],
                asset_instance_id=asset_instance["id"],
                revision=revision,
                name=args["name"],
                representation=args["representation"],
                comment=args["comment"],
                extension=args["extension"]
            )

            output_file_dict = self.add_path_info(
                output_file,
                "output",
                asset_instance,
                output_type,
                task_type=task_type,
                name=args["name"],
                extension=args["extension"],
                representation=args["representation"],
                separator=args["sep"]
            )
        except OutputTypeNotFoundException:
            return {"message": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"message": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"message": "The given output file already exists."}, 400

        return output_file_dict, 201
예제 #10
0
 def check_read_permissions(self, instance):
     if permissions.has_admin_permissions():
         return True
     else:
         asset_instance = self.get_model_or_404(instance["id"])
         asset = assets_service.get_asset(asset_instance.asset_id)
         return user_service.check_project_access(asset["project_id"])
예제 #11
0
파일: resources.py 프로젝트: connectdtk/zou
 def get(self, asset_id):
     """
     Retrieve all asset instances instantiated inside this asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return breakdown_service.get_asset_instances_for_asset(asset_id)
예제 #12
0
 def test_add_asset_link(self):
     self.generate_fixture_asset_types()
     self.generate_fixture_asset_character()
     assets_service.add_asset_link(self.asset.id, self.asset_character.id)
     asset = assets_service.get_asset(self.asset.id)
     self.assertEquals(asset["entities_out"][0],
                       str(self.asset_character.id))
예제 #13
0
    def get(self, asset_instance_id):
        asset_instance = assets_service.get_asset_instance(asset_instance_id)
        asset = assets_service.get_asset(asset_instance["asset_id"])
        user_service.check_project_access(asset["project_id"])

        temporal_entity_id = request.args.get("temporal_entity_id")
        task_type_id = request.args.get("task_type_id")
        output_type_id = request.args.get("output_type_id")
        name = request.args.get("name")
        representation = request.args.get("representation")
        file_status_id = request.args.get("file_status_id")
        created_at_since = request.args.get("created_at_since")
        person_id = request.args.get("person_id")

        return files_service.get_output_files_for_instance(
            asset_instance["id"],
            temporal_entity_id=temporal_entity_id,
            task_type_id=task_type_id,
            output_type_id=output_type_id,
            name=name,
            representation=representation,
            file_status_id=file_status_id,
            created_at_since=created_at_since,
            person_id=person_id,
        )
예제 #14
0
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])
            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"])
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                working_file_id = None

            asset_instance = assets_service.get_asset_instance(
                asset_instance_id)

            entity = assets_service.get_asset(asset_instance["asset_id"])
            user_service.check_project_access(entity["project_id"])

            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file_dict = files_service.create_new_output_revision(
                asset_instance["asset_id"],
                working_file_id,
                output_type["id"],
                person["id"],
                task_type["id"],
                asset_instance_id=asset_instance["id"],
                temporal_entity_id=temporal_entity_id,
                revision=revision,
                name=args["name"],
                path=args["path"],
                render_info=args["render_info"],
                representation=args["representation"],
                comment=args["comment"],
                nb_elements=int(args["nb_elements"]),
                extension=args["extension"],
                file_status_id=args['file_status_id'],
            )

            if args["path"]:
                folder_path, file_name = os.path.split(args["path"])
                output_file_dict.update({
                    "folder_path": folder_path,
                    "file_name": file_name
                })

        except OutputTypeNotFoundException:
            return {"message": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"message": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"message": "The given output file already exists."}, 400

        return output_file_dict, 201
예제 #15
0
파일: resources.py 프로젝트: NeroSouza/zou
 def get(self, asset_id):
     """
     Resource to retrieve the casting of a given asset.
     """
     asset = assets_service.get_asset(asset_id)
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(asset["project_id"])
     return breakdown_service.get_cast_in(asset_id)
예제 #16
0
파일: resources.py 프로젝트: Tesla-Coil/zou
 def is_allowed(self, asset_id):
     asset = assets_service.get_asset(asset_id)
     try:
         if not permissions.has_manager_permissions():
             user_service.check_has_task_related(asset.project_id)
         return True
     except permissions.PermissionDenied:
         return False
예제 #17
0
 def check_update_permissions(self, asset_instance, data):
     if permissions.has_admin_permissions():
         return True
     else:
         asset = assets_service.get_asset(asset_instance["asset_id"])
         user_service.check_project_access(asset["project_id"])
         user_service.check_entity_access(asset["id"])
         return True
예제 #18
0
파일: resources.py 프로젝트: NeroSouza/zou
 def get(self, asset_id):
     """
     Retrieve all task types related to a given asset.
     """
     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_task_types_for_asset(asset_id)
예제 #19
0
파일: resources.py 프로젝트: withgame/zou
 def put(self, asset_id):
     """
     Resource to allow the modification of assets linked to a asset.
     """
     casting = request.json
     asset = assets_service.get_asset(asset_id)
     user_service.check_manager_project_access(asset["project_id"])
     return breakdown_service.update_casting(asset_id, casting)
예제 #20
0
파일: resources.py 프로젝트: NeroSouza/zou
    def get(self, asset_instance_id, output_type_id):
        asset_instance = assets_service.get_asset_instance(asset_instance_id)
        asset = assets_service.get_asset(asset_instance["asset_id"])
        user_service.check_project_access(asset["project_id"])

        files_service.get_output_type(output_type_id)
        return files_service.get_output_files_for_output_type_and_asset_instance(
            asset_instance_id,
            output_type_id
        )
예제 #21
0
 def get(self, asset_id):
     """
     Return task types related to given asset for current user.
     ---
     tags:
     - User
     parameters:
       - in: path
         name: asset_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: Task types related to given asset for current user
     """
     assets_service.get_asset(asset_id)
     return user_service.get_task_types_for_entity(asset_id)
예제 #22
0
 def test_create_asset(self):
     asset = assets_service.create_asset(
         self.project.id,
         self.asset_type.id,
         "New asset",
         "Description test",
         {},
     )
     asset_again = assets_service.get_asset(asset["id"])
     self.assertDictEqual(asset, asset_again)
예제 #23
0
파일: resources.py 프로젝트: connectdtk/zou
 def post(self, asset_id):
     """
     Create an asset instance inside given asset.
     """
     args = self.get_args([("asset_to_instantiate_id", None, True),
                           ("description", None, False)])
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     asset_instance = breakdown_service.add_asset_instance_to_asset(
         asset_id, args["asset_to_instantiate_id"], args["description"])
     return asset_instance, 201
예제 #24
0
def get_base_asset_for_playlist(entity, task_id):
    asset = assets_service.get_asset(entity["id"])
    asset_type = assets_service.get_asset_type(asset["entity_type_id"])
    playlisted_entity = {
        "id": asset["id"],
        "name": asset["name"],
        "preview_file_task_id": task_id,
        "asset_type_id": asset_type["id"],
        "asset_type_name": asset_type["name"],
        "parent_name": asset_type["name"],
    }
    return playlisted_entity
예제 #25
0
    def test_set_main_preview(self):
        entities_service.update_entity_preview(str(self.entity.id),
                                               str(self.preview_file.id))
        asset = assets_service.get_asset(self.entity.id)
        self.assertEquals(asset["preview_file_id"], str(self.preview_file.id))

        with pytest.raises(EntityNotFoundException):
            entities_service.update_entity_preview(str(self.preview_file.id),
                                                   str(self.preview_file.id))

        with pytest.raises(PreviewFileNotFoundException):
            entities_service.update_entity_preview(str(self.entity.id),
                                                   str(self.entity.id))
예제 #26
0
    def get(self, asset_instance_id, temporal_entity_id, output_type_id):
        representation = request.args.get("representation", None)

        asset_instance = assets_service.get_asset_instance(asset_instance_id)
        asset = assets_service.get_asset(asset_instance["asset_id"])
        user_service.check_project_access(asset["project_id"])

        files_service.get_output_type(output_type_id)
        return files_service.get_output_files_for_output_type_and_asset_instance(
            asset_instance_id,
            temporal_entity_id,
            output_type_id,
            representation=representation,
        )
예제 #27
0
파일: resources.py 프로젝트: dsparrow27/zou
    def post(self, project_id, task_type_id):
        user_service.check_manager_project_access(project_id)
        task_type = tasks_service.get_task_type(task_type_id)

        asset_ids = request.json
        assets = []
        if type(asset_ids) == list and len(asset_ids) > 0:
            for asset_id in asset_ids:
                asset = assets_service.get_asset(asset_id)
                if asset["project_id"] == project_id:
                    assets.append(asset)
        else:
            criterions = query.get_query_criterions_from_request(request)
            criterions["project_id"] = project_id
            assets = assets_service.get_assets(criterions)

        tasks = tasks_service.create_tasks(task_type, assets)
        return tasks, 201
예제 #28
0
파일: index_service.py 프로젝트: cgwire/zou
def search_assets(query, project_ids=[], limit=3):
    """
    Perform a search on the index. The query is a simple string. The result is
    a list of assets with extra data like the project name and the asset type
    name (3 results maximum by default).
    """
    index = get_asset_index()
    assets = []

    ids = indexing.search(index, query, project_ids, limit=limit)

    for asset_id in ids:
        asset = assets_service.get_asset(asset_id)
        asset_type = assets_service.get_asset_type(asset["entity_type_id"])
        project = projects_service.get_project(asset["project_id"])
        asset["project_name"] = project["name"]
        asset["asset_type_name"] = asset_type["name"]
        assets.append(asset)
    return assets
예제 #29
0
파일: resources.py 프로젝트: withgame/zou
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        try:
            asset_instance = assets_service.get_asset_instance(
                asset_instance_id)
            entity = entities_service.get_entity(temporal_entity_id)
            asset = assets_service.get_asset(asset_instance["asset_id"])
            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            user_service.check_project_access(asset["project_id"])
            user_service.check_entity_access(asset["id"])

            folder_path = file_tree_service.get_instance_folder_path(
                asset_instance,
                entity,
                output_type=output_type,
                task_type=task_type,
                mode=args["mode"],
                name=args["name"],
                representation=args["representation"],
                revision=args["revision"],
                sep=args["separator"],
            )
            file_name = file_tree_service.get_instance_file_name(
                asset_instance,
                entity,
                output_type=output_type,
                task_type=task_type,
                mode=args["mode"],
                name=args["name"],
                revision=args["revision"],
            )
        except MalformedFileTreeException as exception:
            return (
                {
                    "message": str(exception),
                    "received_data": request.json
                },
                400,
            )

        return {"folder_path": folder_path, "file_name": file_name}, 200
예제 #30
0
파일: resources.py 프로젝트: cgwire/zou
 def get(self, asset_id):
     """
     Retrieve all asset instances instantiated inside this asset.
     ---
     tags:
         - Assets
     parameters:
       - in: path
         name: asset_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25       
     responses:
         200:
             description: All asset instances instantiated inside given asset    
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     return breakdown_service.get_asset_instances_for_asset(asset_id)