示例#1
0
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
示例#2
0
def get_sequences_schedule_items(project_id, task_type_id, episode_id=None):
    """
    Return all asset type schedule items for given project. If no schedule item
    exists for a given asset type, it creates one.
    """
    if episode_id is not None:
        sequences = shots_service.get_sequences_for_episode(episode_id)
    else:
        sequences = shots_service.get_sequences_for_project(project_id)
    sequence_map = base_service.get_model_map_from_array(sequences)
    sequence_type = shots_service.get_sequence_type()

    query = (ScheduleItem.query.join(
        Entity, ScheduleItem.object_id == Entity.id).filter(
            ScheduleItem.project_id == project_id).filter(
                Entity.entity_type_id == sequence_type["id"]).filter(
                    ScheduleItem.task_type_id == task_type_id))
    if episode_id is not None:
        query = query.filter(Entity.parent_id == episode_id)
    existing_schedule_items = set(query.all())

    return get_entity_schedule_items(
        project_id,
        task_type_id,
        sequences,
        sequence_map,
        existing_schedule_items,
    )
示例#3
0
    def test_import_shot(self):
        self.load_fixture("projects")
        self.load_fixture("sequences")
        self.load_fixture("assets")
        self.load_fixture("scenes")

        api_path = "/import/shotgun/shots"
        self.shots = self.post(api_path, [self.sg_shot], 200)
        self.assertEqual(len(self.shots), 1)

        self.shots = self.get("data/shots/all")
        self.assertEqual(len(self.shots), 1)

        shot = self.shots[0]
        shot = shots_service.get_shot_with_relations(shot["id"])
        sequence = Entity.get_by(
            shotgun_id=self.sg_shot["sg_sequence"]["id"],
            entity_type_id=shots_service.get_sequence_type()["id"],
        )
        entity = Entity.get_by(name=self.sg_shot["assets"][0]["name"])
        project = Project.get_by(name=self.sg_shot["project"]["name"])
        scene = Entity.get_by(name=self.sg_shot["sg_scene"]["name"])
        self.assertEqual(shot["name"], self.sg_shot["code"])
        self.assertEqual(shot["data"]["frame_in"], 0)
        self.assertEqual(shot["data"]["frame_out"], 122)
        self.assertEqual(shot["data"]["sg_custom_field"], "test")
        self.assertEqual(shot["parent_id"], str(sequence.id))
        self.assertEqual(shot["entities_out"][0], str(entity.id))
        self.assertEqual(shot["project_id"], str(project.id))
        self.assertEqual(shot["source_id"], str(scene.id))
示例#4
0
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")
示例#5
0
 def get(self):
     """
     Retrieve all sequence, 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_sequence_type()["id"]
     return entities_service.get_entities_and_tasks(criterions)
示例#6
0
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")
示例#7
0
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"],
    ]
示例#8
0
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"],
    ]
示例#9
0
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"]
    ])
示例#10
0
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"],
    ]
示例#11
0
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")
示例#12
0
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()

    edit_type = edits_service.get_edit_type()
    if edit_type is None:
        cache.cache.delete_memoized(edits_service.get_edit_type)
        edit_type = edits_service.get_edit_type()

    ids_to_exclude = [
        shot_type["id"],
        sequence_type["id"],
        episode_type["id"],
        edit_type["id"],
    ]
    if scene_type is not None:
        ids_to_exclude.append(scene_type["id"])

    return ids_to_exclude
示例#13
0
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"],
    ]
示例#14
0
def get_project_sequences(project_id):
    shot_type = shots_service.get_shot_type()
    sequence_type = shots_service.get_sequence_type()

    Shot = aliased(Entity, name='shot')
    query = Entity.query \
        .join(Shot, Shot.parent_id == Entity.id) \
        .join(Task, Task.entity_id == Shot.id) \
        .join(EntityType, EntityType.id == Entity.entity_type_id) \
        .join(Project, Project.id == Entity.project_id) \
        .join(ProjectStatus) \
        .filter(Shot.entity_type_id == shot_type["id"]) \
        .filter(Entity.entity_type_id == sequence_type["id"]) \
        .filter(Project.id == project_id) \
        .filter(assignee_filter()) \
        .filter(open_project_filter())

    return Entity.serialize_list(query.all(), obj_type="Sequence")
    def test_import_scene(self):
        self.load_fixture("projects")
        self.load_fixture("sequences")

        api_path = "/import/shotgun/scenes"
        self.scenes = self.post(api_path, [self.sg_scene], 200)
        self.assertEqual(len(self.scenes), 1)

        self.scenes = self.get("data/scenes/all")
        self.assertEqual(len(self.scenes), 1)

        scene = self.scenes[0]
        sequence = Entity.get_by(
            shotgun_id=self.sg_scene["sequence_sg_scenes_1_sequences"][0]["id"],
            entity_type_id=shots_service.get_sequence_type()["id"]
        )
        project = Project.get_by(name=self.sg_scene["project"]["name"])
        self.assertEqual(scene["name"], self.sg_scene["code"])
        self.assertEqual(scene["parent_id"], str(sequence.id))
        self.assertEqual(scene["project_id"], str(project.id))
示例#16
0
def get_sequences_for_project(project_id):
    """
    Return all sequences 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()

    Shot = aliased(Entity, name='shot')
    query = Entity.query \
        .join(Shot, Shot.parent_id == Entity.id) \
        .join(Task, Task.entity_id == Shot.id) \
        .join(EntityType, EntityType.id == Entity.entity_type_id) \
        .join(Project, Project.id == Entity.project_id) \
        .join(ProjectStatus) \
        .filter(Shot.entity_type_id == shot_type["id"]) \
        .filter(Entity.entity_type_id == sequence_type["id"]) \
        .filter(Project.id == project_id) \
        .filter(build_assignee_filter()) \
        .filter(build_open_project_filter())

    return Entity.serialize_list(query.all(), obj_type="Sequence")
示例#17
0
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
示例#18
0
 def test_get_sequence_type(self):
     sequence_type = shots_service.get_sequence_type()
     self.assertEqual(sequence_type["name"], "Sequence")
示例#19
0
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.")
示例#20
0
 def __init__(self):
     ImportRemoveShotgunBaseResource.__init__(
         self, Entity, entity_type_id=shots_service.get_sequence_type()["id"]
     )
示例#21
0
 def prepare_import(self):
     self.sequence_type = shots_service.get_sequence_type()
     self.project_map = Project.get_id_map(field="name")
示例#22
0
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())
示例#23
0
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"]])