Exemplo n.º 1
0
 def get(self, project_id, asset_type_id):
     """
     Return assets of which type is given asset type and are listed in given project if user has access to this project.
     ---
     tags:
     - User
     parameters:
       - in: path
         name: project_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: asset_type_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: Assets of which type is given asset type and are listed in given project
     """
     projects_service.get_project(project_id)
     assets_service.get_asset_type(asset_type_id)
     return user_service.get_assets_for_asset_type(project_id,
                                                   asset_type_id)
Exemplo n.º 2
0
 def get(self, project_id, asset_type_id):
     """
     Resource to retrieve the casting of assets from given asset type.
     """
     user_service.check_project_access(project_id)
     assets_service.get_asset_type(asset_type_id)
     return breakdown_service.get_asset_type_casting(
         project_id, asset_type_id)
Exemplo n.º 3
0
def get_folder_from_asset_type(asset):
    if asset is not None:
        asset_type = assets_service.get_asset_type(asset["entity_type_id"])
        folder = asset_type["name"]
    else:
        raise MalformedFileTreeException("Given asset is null.")
    return folder
Exemplo n.º 4
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
Exemplo n.º 5
0
 def get_task_types_for_asset_type(self, asset_type_id):
     task_type_ids = [
         str(task_type.id)
         for task_type in self.task_types_in_project_for_assets
     ]
     asset_type = assets_service.get_asset_type(asset_type_id)
     type_task_type_ids = asset_type["task_types"]
     type_task_types_map = {
         task_type_id: True
         for task_type_id in type_task_type_ids
     }
     if len(type_task_type_ids) > 0:
         task_type_ids = [
             task_type_id for task_type_id in task_type_ids
             if task_type_id in type_task_types_map
         ]
     return task_type_ids
Exemplo n.º 6
0
 def get(self, asset_type_id):
     """
     Retrieve given asset type.
     ---
     tags:
       - Assets
     parameters:
       - in: path
         name: asset_type_id
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
         required: True
     responses:
       200:
         description: Given asset type
     """
     return assets_service.get_asset_type(asset_type_id)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
 def get(self, asset_type_id):
     """
     Retrieve given asset type.
     """
     return assets_service.get_asset_type(asset_type_id)
Exemplo n.º 9
0
 def get(self, project_id, asset_type_id):
     projects_service.get_project(project_id)
     assets_service.get_asset_type(asset_type_id)
     return user_service.get_assets_for_asset_type(project_id, asset_type_id)
Exemplo n.º 10
0
 def test_get_asset_type(self):
     asset_type = assets_service.get_asset_type(self.asset_type.id)
     self.assertDictEqual(asset_type,
                          self.asset_type.serialize(obj_type="AssetType"))