Skip to content

Various improvements #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 33 additions & 69 deletions zou/app/blueprints/assets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def check_criterion_access(criterions):


class AssetResource(Resource, ArgsMixin):
"""
Retrieve or delete given asset.
"""


@jwt_required()
def get(self, asset_id):
Expand Down Expand Up @@ -72,7 +70,7 @@ def delete(self, asset_id):
required: True
responses:
204:
description: Given asset deleted
description: Empty response
"""
force = self.get_force()

Expand All @@ -87,15 +85,11 @@ def delete(self, asset_id):


class AllAssetsResource(Resource):
"""
Retrieve all entities that are not shot or sequence.
Adds project name and asset type name.
"""

@jwt_required()
def get(self):
"""
Retrieve all entities that are not shot or sequence.
Retrieve all entities that are not shot, sequence, episode, or edit.
Adds project name and asset type name.
---
tags:
Expand All @@ -121,18 +115,15 @@ class AllAssetsAliasResource(AllAssetsResource):


class AssetsAndTasksResource(Resource, ArgsMixin):
"""
Retrieve all entities that are not shot or sequence.
"""

@jwt_required()
def get(self):
"""
Retrieve all entities that are not shot or sequence.
Retrieve all entities that are not shot, sequence, episode, or edit.
Adds project name and asset type name and all related tasks.
If episode_id is given as parameter, it returns assets not linked
to an episode and assets linked to given episode.
---
description: Adds project name and asset type name and all related tasks.
If episode_id is given as parameter, it returns assets not linked
to an episode and assets linked to given episode.
tags:
- Assets
responses:
Expand All @@ -153,9 +144,6 @@ def get(self):


class AssetTypeResource(Resource):
"""
Retrieve given asset type.
"""

@jwt_required()
def get(self, asset_type_id):
Expand All @@ -179,9 +167,6 @@ def get(self, asset_type_id):


class AssetTypesResource(Resource):
"""
Retrieve all asset types (entity types that are not shot, sequence or episode).
"""

@jwt_required()
def get(self):
Expand All @@ -199,9 +184,6 @@ def get(self):


class ProjectAssetTypesResource(Resource):
"""
Retrieve all asset types for given project.
"""

@jwt_required()
def get(self, project_id):
Expand All @@ -226,14 +208,11 @@ def get(self, project_id):


class ShotAssetTypesResource(Resource):
"""
Retrieve all asset shots for given shot.
"""

@jwt_required()
def get(self, shot_id):
"""
Retrieve all asset shots for given shot.
Retrieve all asset types of assets casted in given shot.
---
tags:
- Assets
Expand All @@ -246,17 +225,14 @@ def get(self, shot_id):
required: True
responses:
200:
description: All asset shots for given shot
description: All asset types of assets casted in given shot
"""
shot = shots_service.get_shot(shot_id)
user_service.check_project_access(shot["project_id"])
return assets_service.get_asset_types_for_shot(shot_id)


class ProjectAssetsResource(Resource):
"""
Retrieve all assets for given project.
"""

@jwt_required()
def get(self, project_id):
Expand Down Expand Up @@ -287,14 +263,11 @@ def get(self, project_id):


class ProjectAssetTypeAssetsResource(Resource):
"""
Retrieve all assets for given project and entity type.
"""

@jwt_required()
def get(self, project_id, asset_type_id):
"""
Retrieve all assets for given project and entity type.
Retrieve all assets for given project and asset type.
---
tags:
- Assets
Expand All @@ -313,7 +286,7 @@ def get(self, project_id, asset_type_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All assets for given project and entity type
description: All assets for given project and asset type
"""
user_service.check_project_access(project_id)
criterions = query.get_query_criterions_from_request(request)
Expand All @@ -327,14 +300,11 @@ def get(self, project_id, asset_type_id):


class AssetAssetsResource(Resource):
"""
Retrieve all assets for a given asset.
"""

@jwt_required()
def get(self, asset_id):
"""
Retrieve all assets for a given asset.
Retrieve all assets linked to given asset.
---
tags:
- Assets
Expand All @@ -347,7 +317,7 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All assets for a given asset
description: All assets linked to given asset
"""
asset = assets_service.get_asset(asset_id)
user_service.check_project_access(asset["project_id"])
Expand All @@ -356,10 +326,11 @@ def get(self, asset_id):


class AssetTasksResource(Resource, ArgsMixin):

@jwt_required()
def get(self, asset_id):
"""
Retrieve all tasks related to a given shot.
Retrieve all tasks related to given asset.
---
tags:
- Assets
Expand All @@ -372,7 +343,7 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All tasks related to given shot
description: All tasks related to given asset
"""
asset = assets_service.get_asset(asset_id)
user_service.check_project_access(asset["project_id"])
Expand All @@ -382,10 +353,11 @@ def get(self, asset_id):


class AssetTaskTypesResource(Resource):

@jwt_required()
def get(self, asset_id):
"""
Retrieve all task types related to a given asset.
Retrieve all task types of tasks related to given asset.
---
tags:
- Assets
Expand All @@ -398,22 +370,19 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All task types related to given asset
description: All task types of tasks related to 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)


class NewAssetResource(Resource, ArgsMixin):
"""
Create new asset resource.
"""

@jwt_required()
def post(self, project_id, asset_type_id):
"""
Create new asset resource.
Create new asset with given parameters.
---
tags:
- Assets
Expand Down Expand Up @@ -503,10 +472,11 @@ def get_arguments(self):


class AssetCastingResource(Resource):

@jwt_required()
def get(self, asset_id):
"""
Resource to retrieve the casting of a given asset.
Retrieve the casting of a given asset.
---
tags:
- Assets
Expand All @@ -529,7 +499,7 @@ def get(self, asset_id):
@jwt_required()
def put(self, asset_id):
"""
Resource to allow the modification of assets linked to a asset.
Modify the casting of given asset.
---
tags:
- Assets
Expand All @@ -551,10 +521,11 @@ def put(self, asset_id):


class AssetCastInResource(Resource):

@jwt_required()
def get(self, asset_id):
"""
Resource to retrieve the casting of a given asset.
Retrieve the list of shots that cast given asset.
---
tags:
- Assets
Expand All @@ -567,7 +538,7 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: Casting of given asset
description: List of shots that cast given asset
"""
asset = assets_service.get_asset(asset_id)
user_service.check_project_access(asset["project_id"])
Expand All @@ -576,10 +547,11 @@ def get(self, asset_id):


class AssetShotAssetInstancesResource(Resource):

@jwt_required()
def get(self, asset_id):
"""
Retrieve all shot asset instances linked to asset.
Retrieve all shot asset instances linked to given asset.
---
tags:
- Assets
Expand All @@ -592,7 +564,7 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All shot asset instances linked to asset
description: All shot asset instances linked to given asset
"""
asset = assets_service.get_asset(asset_id)
user_service.check_project_access(asset["project_id"])
Expand All @@ -603,7 +575,7 @@ class AssetSceneAssetInstancesResource(Resource):
@jwt_required()
def get(self, asset_id):
"""
Retrieve all scene asset instances linked to asset.
Retrieve all scene asset instances linked to given asset.
---
tags:
- Assets
Expand All @@ -616,7 +588,7 @@ def get(self, asset_id):
x-example: a24a6ea4-ce75-4665-a070-57453082c25
responses:
200:
description: All scene asset instances linked to asset
description: All scene asset instances linked to given asset
"""
asset = assets_service.get_asset(asset_id)
user_service.check_project_access(asset["project_id"])
Expand All @@ -627,7 +599,7 @@ class AssetAssetInstancesResource(Resource, ArgsMixin):
@jwt_required()
def get(self, asset_id):
"""
Retrieve all asset instances instantiated inside this asset.
Retrieve all asset instances instantiated inside given asset.
---
tags:
- Assets
Expand Down Expand Up @@ -702,9 +674,6 @@ def post(self, project_id=None, asset_type_id=None, asset_ids=None):


class SetSharedProjectAssetsResource(BaseSetSharedAssetsResource):
"""
Share or unshare all assets (or a list of assets) for given project.
"""

@jwt_required()
def post(self, project_id):
Expand Down Expand Up @@ -754,9 +723,6 @@ def post(self, project_id):


class SetSharedProjectAssetTypeAssetsResource(BaseSetSharedAssetsResource):
"""
Share or unshare all assets for given project and asset type.
"""

@jwt_required()
def post(self, project_id, asset_type_id):
Expand Down Expand Up @@ -794,9 +760,6 @@ def post(self, project_id, asset_type_id):


class SetSharedAssetsResource(BaseSetSharedAssetsResource):
"""
Share or unshare all assets (or a list of assets) for given project.
"""

@jwt_required()
def post(self):
Expand Down Expand Up @@ -868,6 +831,7 @@ def get(self, project_id):


class ProjectEpisodeAssetsSharedUsedResource(Resource):

@jwt_required()
def get(self, project_id, episode_id):
"""
Expand Down
7 changes: 7 additions & 0 deletions zou/app/blueprints/projects/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,13 @@ def put(self, project_id, budget_id, entry_id):
("daily_salary", None, False),
("position", None, False),
("seniority", None, False),
{
"name": "exceptions",
"required": False,
"default": {},
"type": dict,
"help": "Map of amount exceptions. Key is the date and value is the amount. Example: {'2025-01-01': 1000, '2025-02-01': 2000}",
}
]
)
return budget_service.update_budget_entry(entry_id, data)
Expand Down
3 changes: 3 additions & 0 deletions zou/app/blueprints/source/csv/task_type_estimations.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def import_row(self, row, project_id, task_type_id, episode_id=None):
* 60
)

if row.get("Drawings") not in [None, ""]:
new_data["nb_drawings"] = int(row["Drawings"])

if row.get("Start date") not in [None, ""]:
new_data["start_date"] = date_helpers.get_date_from_string(
row["Start date"]
Expand Down
Loading