def get_temporal_type_ids(): shot_type = shots_service.get_shot_type() if shot_type is None: cache.cache.delete_memoized(shots_service.get_shot_type) shot_type = shots_service.get_shot_type() scene_type = shots_service.get_scene_type() if scene_type is None: cache.cache.delete_memoized(shots_service.get_scene_type) scene_type = shots_service.get_scene_type() sequence_type = shots_service.get_sequence_type() if sequence_type is None: cache.cache.delete_memoized(shots_service.get_sequence_type) sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() if episode_type is None: cache.cache.delete_memoized(shots_service.get_episode_type) episode_type = shots_service.get_episode_type() ids_to_exclude = [shot_type["id"], sequence_type["id"], episode_type["id"]] if scene_type is not None: ids_to_exclude.append(scene_type["id"]) return ids_to_exclude
def init_data(): projects_service.get_open_status() projects_service.get_closed_status() print("Project status initialized.") assets_service.get_or_create_type("Characters") assets_service.get_or_create_type("Props") assets_service.get_or_create_type("Environment") assets_service.get_or_create_type("FX") assets_service.get_or_create_type("Camera") print("Asset types initialized.") shots_service.get_episode_type() shots_service.get_sequence_type() shots_service.get_shot_type() print("Shot types initialized.") modeling = tasks_service.get_or_create_department("Modeling") animation = tasks_service.get_or_create_department("Animation") fx = tasks_service.get_or_create_department("FX") compositing = tasks_service.get_or_create_department("Compositing") concept = tasks_service.get_or_create_department("Concept") layout = tasks_service.get_or_create_department("Layout") tasks_service.get_or_create_task_type(concept, "Concept", "#8D6E63", 1) tasks_service.get_or_create_task_type(modeling, "Texture", "#64B5F6", 2) tasks_service.get_or_create_task_type(modeling, "Modeling", "#78909C", 3) tasks_service.get_or_create_task_type(animation, "Setup", "#9CCC65", 4) tasks_service.get_or_create_task_type(concept, "Storyboard", "#43A047", 1, True) tasks_service.get_or_create_task_type(layout, "Layout", "#7CB342", 2, True) tasks_service.get_or_create_task_type(animation, "Animation", "#009688", 3, True) tasks_service.get_or_create_task_type(compositing, "Lighting", "#F9A825", 4, True) tasks_service.get_or_create_task_type(fx, "FX", "#26C6DA", 5, True) tasks_service.get_or_create_task_type(compositing, "Render", "#F06292", 6, True) tasks_service.get_or_create_task_type(compositing, "Compositing", "#ff5252", 7, True) print("Task types initialized.") tasks_service.get_or_create_status("Todo", "todo", "#f5f5f5") tasks_service.get_or_create_status("Work In Progress", "wip", "#3273dc") tasks_service.get_or_create_status("Waiting For Approval", "wfa", "#ab26ff", is_reviewable=True) tasks_service.get_or_create_status("Retake", "retake", "#ff3860", is_reviewable=True) tasks_service.get_or_create_status("Done", "done", "#22d160", is_done=True) print("Task status initialized.")
def get_project_episodes(project_id): """ Return all episodes for given project and for which current user has a task assigned to a shot. """ shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() Shot = aliased(Entity, name="shot") Sequence = aliased(Entity, name="sequence") query = ( Entity.query.join(Sequence, Sequence.parent_id == Entity.id) .join(Shot, Shot.parent_id == Sequence.id) .join(Task, Task.entity_id == Shot.id) .join(Project, Project.id == Entity.project_id) .join(ProjectStatus) .filter(Shot.entity_type_id == shot_type["id"]) .filter(Sequence.entity_type_id == sequence_type["id"]) .filter(Entity.entity_type_id == episode_type["id"]) .filter(Project.id == project_id) .filter(build_assignee_filter()) .filter(build_open_project_filter()) ) return Entity.serialize_list(query.all(), obj_type="Episode")
def guess_shot(project, episode_name, sequence_name, shot_name): episode_id = None if len(episode_name) > 0: episode = Entity.get_by( name=episode_name, entity_type_id=shots_service.get_episode_type()["id"], project_id=project["id"], ) if episode is not None: episode_id = episode.id sequence_id = None if len(sequence_name) > 0: sequence = Entity.get_by( name=sequence_name, entity_type_id=shots_service.get_sequence_type()["id"], parent_id=episode_id, project_id=project["id"], ) if sequence is not None: sequence_id = sequence.id else: sequence_id = None if len(shot_name) > 0: shot = Entity.get_by( name=shot_name, entity_type_id=shots_service.get_shot_type()["id"], parent_id=sequence_id, project_id=project["id"], ) else: raise WrongPathFormatException("Shot name was not found in given path") return shot
def get(self): """ Retrieve all episode, adds project name and asset type name and all related tasks. """ criterions = query.get_query_criterions_from_request(request) user_service.check_project_access(criterions.get("project_id", None)) criterions["entity_type_id"] = shots_service.get_episode_type()["id"] return entities_service.get_entities_and_tasks(criterions)
def get_assets(criterions={}): shot_type = shots_service.get_shot_type() scene_type = shots_service.get_scene_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() query = Entity.query.filter_by(**criterions) result = query.filter(~Entity.entity_type_id.in_([ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"] ])).all() return EntityType.serialize_list(result, obj_type="Asset")
def is_asset_type(asset_type): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() scene_type = shots_service.get_scene_type() episode_type = shots_service.get_episode_type() return str(asset_type.id) not in [ shot_type["id"], sequence_type["id"], scene_type["id"], episode_type["id"], ]
def is_asset(entity): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() scene_type = shots_service.get_scene_type() episode_type = shots_service.get_episode_type() return str(entity.entity_type_id) not in [ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"], ]
def build_entity_type_asset_type_filter(): """ Generate a query filter to filter entity types that are asset types (it means not shot, not sequence, not episode and not scene) """ shot_type = shots_service.get_shot_type() scene_type = shots_service.get_scene_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() return ~EntityType.id.in_([ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"] ])
def is_asset_type(entity_type): """ Returns true if given entity type is an asset, not a shot. """ shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() scene_type = shots_service.get_scene_type() episode_type = shots_service.get_episode_type() return str(entity_type.id) not in [ shot_type["id"], sequence_type["id"], scene_type["id"], episode_type["id"], ]
def get_asset_types(criterions={}): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() scene_type = shots_service.get_scene_type() asset_type_filter = ~EntityType.id.in_([ shot_type["id"], sequence_type["id"], episode_type["id"], scene_type["id"], ]) query = EntityType.query \ .filter_by(**criterions) \ .filter(asset_type_filter) return EntityType.serialize_list(query.all(), obj_type="AssetType")
def build_main_pack_results(self, project_id): results = [] ParentAsset = aliased(Entity, name="parent_asset") ParentAssetType = aliased(EntityType, name="parent_asset_type") Asset = aliased(Entity, name="asset") AssetType = aliased(EntityType, name="asset_type") shot_type = shots_service.get_shot_type() episode_type = shots_service.get_episode_type() query = (EntityLink.query.join( ParentAsset, EntityLink.entity_in_id == ParentAsset.id).join( ParentAssetType, ParentAsset.entity_type_id == ParentAssetType.id, ).join(Asset, EntityLink.entity_out_id == Asset.id).join( AssetType, Asset.entity_type_id == AssetType.id).filter( ParentAsset.project_id == project_id).filter( ParentAsset.source_id == None).filter( ParentAssetType.id != shot_type["id"]).filter( ParentAssetType.id != episode_type["id"])) query = query.add_columns( ParentAssetType.name, ParentAsset.name, AssetType.name, Asset.name, ).order_by( ParentAssetType.name, ParentAsset.name, AssetType.name, Asset.name, ) for ( entity_link, parent_asset_type_name, parent_name, asset_type_name, asset_name, ) in query.all(): results.append(( "MP", "", parent_asset_type_name, parent_name, asset_type_name, asset_name, entity_link.nb_occurences, entity_link.label, )) return results
def is_asset_dict(entity): """ Returns true if given entity is an asset, not a shot. It supposes that the entity is represented as a dict. """ shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() scene_type = shots_service.get_scene_type() episode_type = shots_service.get_episode_type() return entity["entity_type_id"] not in [ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"], ]
def get_episodes_schedule_items(project_id, task_type_id): """ Return all episode schedule items for given project. If no schedule item exists for a given asset type, it creates one. """ episode_type = shots_service.get_episode_type() episodes = shots_service.get_episodes_for_project(project_id) episodes_map = base_service.get_model_map_from_array(episodes) existing_schedule_items = set( ScheduleItem.query.join( Entity, ScheduleItem.object_id == Entity.id).filter( ScheduleItem.project_id == project_id).filter( Entity.entity_type_id == episode_type["id"]).filter( ScheduleItem.task_type_id == task_type_id).all()) return get_entity_schedule_items( project_id, task_type_id, episodes, episodes_map, existing_schedule_items, )
def get_project_episodes(project_id): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() Shot = aliased(Entity, name='shot') Sequence = aliased(Entity, name='sequence') query = Entity.query \ .join(Sequence, Sequence.parent_id == Entity.id) \ .join(Shot, Shot.parent_id == Sequence.id) \ .join(Task, Task.entity_id == Shot.id) \ .join(Project, Project.id == Entity.project_id) \ .join(ProjectStatus) \ .filter(Shot.entity_type_id == shot_type["id"]) \ .filter(Sequence.entity_type_id == sequence_type["id"]) \ .filter(Entity.entity_type_id == episode_type["id"]) \ .filter(Project.id == project_id) \ .filter(assignee_filter()) \ .filter(open_project_filter()) return Entity.serialize_list(query.all(), obj_type="Episode")
def all_assets(criterions={}): shot_type = shots_service.get_shot_type() scene_type = shots_service.get_scene_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() query = Entity.query.filter_by(**criterions) query = query.filter(~Entity.entity_type_id.in_([ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"] ])) query = query.join(Project) query = query.join(EntityType) query = query.add_columns(Project.name) query = query.add_columns(EntityType.name) data = query.all() assets = [] for (asset_model, project_name, asset_type_name) in data: asset = asset_model.serialize(obj_type="Asset") asset["project_name"] = project_name asset["asset_type_name"] = asset_type_name assets.append(asset) return assets
def __init__(self): ImportRemoveShotgunBaseResource.__init__( self, Entity, entity_type_id=shots_service.get_episode_type()["id"])
def prepare_import(self): self.episode_type = shots_service.get_episode_type() self.project_map = Project.get_id_map(field="name")
def test_get_episode_type(self): episode_type = shots_service.get_episode_type() self.assertEqual(episode_type["name"], "Episode")
def asset_type_filter(): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() return ~EntityType.id.in_( [shot_type["id"], sequence_type["id"], episode_type["id"]])
def init_data(): """ Put the minimum required data into the database to start with it. """ projects_service.get_open_status() projects_service.get_closed_status() print("Project status initialized.") assets_service.get_or_create_asset_type("Characters") assets_service.get_or_create_asset_type("Props") assets_service.get_or_create_asset_type("Environment") assets_service.get_or_create_asset_type("FX") print("Asset types initialized.") shots_service.get_episode_type() shots_service.get_sequence_type() shots_service.get_shot_type() print("Shot types initialized.") modeling = tasks_service.get_or_create_department("Modeling") animation = tasks_service.get_or_create_department("Animation") fx = tasks_service.get_or_create_department("FX") compositing = tasks_service.get_or_create_department("Compositing") concept = tasks_service.get_or_create_department("Concept") layout = tasks_service.get_or_create_department("Layout") tasks_service.get_or_create_task_type(concept, "Concept", "#8D6E63", 1) tasks_service.get_or_create_task_type(modeling, "Modeling", "#78909C", 2) tasks_service.get_or_create_task_type(modeling, "Shading", "#64B5F6", 3) tasks_service.get_or_create_task_type(animation, "Rigging", "#9CCC65", 4) tasks_service.get_or_create_task_type( concept, "Storyboard", "#43A047", priority=1, for_shots=True, for_entity="Shot", ) tasks_service.get_or_create_task_type( layout, "Layout", "#7CB342", priority=2, for_shots=True, for_entity="Shot", ) tasks_service.get_or_create_task_type( animation, "Animation", "#009688", priority=3, for_shots=True, for_entity="Shot", ) tasks_service.get_or_create_task_type( compositing, "Lighting", "#F9A825", priority=4, for_shots=True, for_entity="Shot", ) tasks_service.get_or_create_task_type(fx, "FX", "#26C6DA", priority=5, for_shots=True, for_entity="Shot") tasks_service.get_or_create_task_type( compositing, "Rendering", "#F06292", priority=6, for_shots=True, for_entity="Shot", ) tasks_service.get_or_create_task_type( compositing, "Compositing", "#ff5252", priority=7, for_shots=True, for_entity="Shot", ) print("Task types initialized.") tasks_service.get_or_create_status("Todo", "todo", "#f5f5f5") tasks_service.get_or_create_status("Work In Progress", "wip", "#3273dc") tasks_service.get_or_create_status("Waiting For Approval", "wfa", "#ab26ff") tasks_service.get_or_create_status("Retake", "retake", "#ff3860", is_retake=True) tasks_service.get_or_create_status("Done", "done", "#22d160", is_done=True) print("Task status initialized.")
def all_assets_and_tasks(criterions={}, page=1): shot_type = shots_service.get_shot_type() sequence_type = shots_service.get_sequence_type() episode_type = shots_service.get_episode_type() scene_type = shots_service.get_scene_type() asset_map = {} task_map = {} query = Entity.query \ .join(EntityType) \ .outerjoin(Task) \ .outerjoin(assignees_table) \ .add_columns( EntityType.name, Task.id, Task.task_type_id, Task.task_status_id, assignees_table.columns.person ) \ .order_by( EntityType.name, Entity.name ) \ .filter( ~Entity.entity_type_id.in_([ shot_type["id"], scene_type["id"], sequence_type["id"], episode_type["id"] ]) ) if "project_id" in criterions: query = query.filter(Entity.project_id == criterions["project_id"]) for (asset, entity_type_name, task_id, task_type_id, task_status_id, person_id) in query.all(): if asset.id not in asset_map: asset_map[asset.id] = { "id": str(asset.id), "name": asset.name, "preview_file_id": str(asset.preview_file_id or ""), "description": asset.description, "asset_type_name": entity_type_name, "asset_type_id": str(asset.entity_type_id), "canceled": asset.canceled, "data": fields.serialize_value(asset.data), "tasks": [] } if task_id is not None: if task_id not in task_map: task_dict = { "id": str(task_id), "entity_id": str(asset.id), "task_status_id": str(task_status_id), "task_type_id": str(task_type_id), "assignees": [] } task_map[task_id] = task_dict asset_dict = asset_map[asset.id] asset_dict["tasks"].append(task_dict) if person_id: task_map[task_id]["assignees"].append(str(person_id)) return list(asset_map.values())