Skip to content

Commit

Permalink
Merge pull request #858 from NicoPennec/fix/shared-assets
Browse files Browse the repository at this point in the history
Fix shared assets
  • Loading branch information
frankrousseau authored Sep 10, 2024
2 parents 812c5d2 + 4a7d5a0 commit 607c0d9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
13 changes: 12 additions & 1 deletion zou/app/blueprints/assets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def post(self, project_id, asset_type_id):
- name
- description
- data
- is_shared
- source_id
properties:
name:
Expand All @@ -443,6 +444,8 @@ def post(self, project_id, asset_type_id):
type: string
data:
type: string
is_shared:
type: boolean
source_id:
type: string
format: UUID
Expand All @@ -451,7 +454,7 @@ def post(self, project_id, asset_type_id):
201:
description: New asset resource created
"""
(name, description, data, source_id) = self.get_arguments()
(name, description, data, is_shared, source_id) = self.get_arguments()

user_service.check_manager_project_access(project_id)
asset = assets_service.create_asset(
Expand All @@ -460,6 +463,7 @@ def post(self, project_id, asset_type_id):
name,
description,
data,
is_shared,
source_id,
created_by=persons_service.get_current_user()["id"],
)
Expand All @@ -475,6 +479,12 @@ def get_arguments(self):
},
"description",
("data", {}, False, dict),
(
"is_shared",
True,
False,
bool,
),
"episode_id",
]
)
Expand All @@ -483,6 +493,7 @@ def get_arguments(self):
args["name"],
args.get("description", ""),
args["data"],
args["is_shared"],
args["episode_id"],
)

Expand Down
3 changes: 3 additions & 0 deletions zou/app/services/assets_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def get_assets_and_tasks(criterions={}, page=1, with_episode_ids=False):
"episode_id": source_id,
"casting_episode_ids": cast_in_episode_ids.get(asset_id, []),
"is_casting_standby": asset.is_casting_standby,
"is_shared": asset.is_shared,
"data": data,
"tasks": [],
}
Expand Down Expand Up @@ -571,6 +572,7 @@ def create_asset(
name,
description,
data,
is_shared=False,
source_id=None,
created_by=None,
):
Expand All @@ -587,6 +589,7 @@ def create_asset(
name=name,
description=description,
data=data,
is_shared=is_shared,
source_id=source_id,
created_by=created_by,
)
Expand Down
30 changes: 27 additions & 3 deletions zou/app/services/breakdown_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,27 @@ def get_production_episodes_casting(project_id):
.join(EntityType, Entity.entity_type_id == EntityType.id)
.filter(Episode.project_id == project_id)
.filter(Entity.canceled != True)
.add_columns(Entity.name, EntityType.name, Entity.preview_file_id)
.order_by(EntityType.name, Entity.name)
.add_columns(
Entity.name,
EntityType.name,
Entity.preview_file_id,
Entity.is_shared,
Entity.project_id,
)
.order_by(
EntityType.name,
Entity.name,
)
)

for link, entity_name, entity_type_name, entity_preview_file_id in links:
for (
link,
entity_name,
entity_type_name,
entity_preview_file_id,
entity_is_shared,
entity_project_id,
) in links:
episode_id = str(link.entity_in_id)
if episode_id not in castings:
castings[episode_id] = []
Expand All @@ -118,6 +134,8 @@ def get_production_episodes_casting(project_id):
),
"nb_occurences": link.nb_occurences,
"label": link.label,
"is_shared": entity_is_shared,
"project_id": entity_project_id,
}
)
return castings
Expand Down Expand Up @@ -145,6 +163,8 @@ def get_sequence_casting(sequence_id, project_id=None, episode_id=None):
Entity.name,
EntityType.name,
Entity.preview_file_id,
Entity.is_shared,
Entity.project_id,
Sequence.name,
)
)
Expand All @@ -169,6 +189,8 @@ def get_sequence_casting(sequence_id, project_id=None, episode_id=None):
entity_name,
entity_type_name,
entity_preview_file_id,
entity_is_shared,
entity_project_id,
sequence_name,
) in links:
shot_id = str(link.entity_in_id)
Expand All @@ -186,6 +208,8 @@ def get_sequence_casting(sequence_id, project_id=None, episode_id=None):
),
"nb_occurences": link.nb_occurences,
"label": link.label,
"is_shared": entity_is_shared,
"project_id": entity_project_id,
}
)
return castings
Expand Down

0 comments on commit 607c0d9

Please sign in to comment.