Beispiel #1
0
def update_casting(shot_id, casting):
    shot = shots_service.get_shot_raw(shot_id)
    shot.update({"entities_out": []})
    for cast in casting:
        EntityLink.create(entity_in_id=shot.id,
                          entity_out_id=cast["asset_id"],
                          nb_occurences=cast["nb_occurences"])
    return casting
Beispiel #2
0
def update_casting(shot_id, casting):
    """
    Update casting for given shot. Casting is an array of dictionaries made of
    two fields: `asset_id` and `nb_occurences`.
    """
    shot = shots_service.get_shot_raw(shot_id)
    shot.update({"entities_out": []})
    for cast in casting:
        EntityLink.create(entity_in_id=shot.id,
                          entity_out_id=cast["asset_id"],
                          nb_occurences=cast["nb_occurences"])
    return casting
Beispiel #3
0
def create_casting_link(entity_in_id, asset_id, nb_occurences=1, label=""):
    """
    Add a link between given entity and given asset.
    """
    link = EntityLink.get_by(entity_in_id=entity_in_id, entity_out_id=asset_id)
    entity = entities_service.get_entity(entity_in_id)
    project_id = str(entity["project_id"])
    if link is None:
        link = EntityLink.create(
            entity_in_id=entity_in_id,
            entity_out_id=asset_id,
            nb_occurences=nb_occurences,
            label=label,
        )
        events.emit("entity-link:new", {
            "entity_link_id": link.id,
            "entity_in_id": link.entity_in_id,
            "entity_out_id": link.entity_out_id,
            "nb_occurences": nb_occurences
        },
                    project_id=project_id)
    else:
        link.update({"nb_occurences": nb_occurences, "label": label})
        events.emit("entity-link:update", {
            "entity_link_id": link.id,
            "nb_occurences": nb_occurences
        },
                    project_id=project_id)
    return link
Beispiel #4
0
def update_casting(shot_id, casting):
    """
    Update casting for given shot. Casting is an array of dictionaries made of
    two fields: `asset_id` and `nb_occurences`.
    """
    shot = shots_service.get_shot_raw(shot_id)
    shot.update({"entities_out": []})
    casting_ids = []
    for cast in casting:
        if "asset_id" in cast and "nb_occurences" in cast:
            EntityLink.create(entity_in_id=shot.id,
                              entity_out_id=cast["asset_id"],
                              nb_occurences=cast["nb_occurences"])
    events.emit("shot:casting-update", {
        "shot": shot_id,
        "casting": casting_ids
    })
    return casting
Beispiel #5
0
def create_casting_link(entity_in_id, asset_id, nb_occurences=1, label=""):
    """
    Add a link between given entity and given asset.
    """
    link = EntityLink.get_by(entity_in_id=entity_in_id, entity_out_id=asset_id)
    if link is None:
        link = EntityLink.create(
            entity_in_id=entity_in_id,
            entity_out_id=asset_id,
            nb_occurences=nb_occurences,
            label=label,
        )
    else:
        link.update({"nb_occurences": nb_occurences, "label": label})
    return link
Beispiel #6
0
def _create_episode_casting_link(entity, asset_id, nb_occurences=1, label=""):
    """
    When an asset is casted in a shot, the asset is automatically casted in
    the episode.
    """
    if shots_service.is_shot(entity):
        sequence = shots_service.get_sequence(entity["parent_id"])
        if sequence["parent_id"] is not None:
            link = EntityLink.get_by(entity_in_id=sequence["parent_id"],
                                     entity_out_id=asset_id)
            if link is None:
                link = EntityLink.create(
                    entity_in_id=sequence["parent_id"],
                    entity_out_id=asset_id,
                    nb_occurences=1,
                    label=label,
                )
                events.emit(
                    "asset:update",
                    {"asset_id": asset_id},
                    project_id=entity["project_id"],
                )
    return entity