예제 #1
0
파일: resources.py 프로젝트: NeroSouza/zou
    def post(self, entity_id):
        args = self.get_arguments()
        entity = entities_service.get_entity(entity_id)
        output_type = files_service.get_output_type(args["output_type_id"])
        task_type = tasks_service.get_task_type(args["task_type_id"])
        if not permissions.has_manager_permissions():
            user_service.check_has_task_related(entity["project_id"])

        next_revision_number = \
            files_service.get_next_output_file_revision(
                entity["id"],
                output_type["id"],
                task_type["id"],
                args["name"]
            )

        return {
            "next_revision": next_revision_number
        }, 200
예제 #2
0
파일: resources.py 프로젝트: indextbag/zou
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        asset_instance = assets_service.get_asset_instance(asset_instance_id)
        asset = entities_service.get_entity(asset_instance["asset_id"])
        output_type = files_service.get_output_type(args["output_type_id"])
        task_type = tasks_service.get_task_type(args["task_type_id"])
        user_service.check_project_access(asset["project_id"])

        next_revision_number = files_service.get_next_output_file_revision(
            asset["id"],
            output_type["id"],
            task_type["id"],
            args["name"],
            asset_instance_id=asset_instance["id"],
            temporal_entity_id=temporal_entity_id,
        )

        return {"next_revision": next_revision_number}, 200
예제 #3
0
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        try:
            asset_instance = assets_service.get_asset_instance(
                asset_instance_id)
            entity = entities_service.get_entity(temporal_entity_id)
            asset = assets_service.get_asset(asset_instance["asset_id"])
            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            user_service.check_project_access(asset["project_id"])
            user_service.check_entity_access(asset["id"])

            folder_path = file_tree_service.get_instance_folder_path(
                asset_instance,
                entity,
                output_type=output_type,
                task_type=task_type,
                mode=args["mode"],
                name=args["name"],
                representation=args["representation"],
                revision=args["revision"],
                sep=args["separator"],
            )
            file_name = file_tree_service.get_instance_file_name(
                asset_instance,
                entity,
                output_type=output_type,
                task_type=task_type,
                mode=args["mode"],
                name=args["name"],
                revision=args["revision"],
            )
        except MalformedFileTreeException as exception:
            return (
                {
                    "message": str(exception),
                    "received_data": request.json
                },
                400,
            )

        return {"folder_path": folder_path, "file_name": file_name}, 200
예제 #4
0
    def post(self, file_id):
        args = self.get_arguments()

        try:
            file_dict = files_service.get_output_file(file_id)
            entity = entities_service.get_entity(file_dict["entity_id"])
            user_service.check_project_access(entity["project_id"])
            user_service.check_entity_access(entity["id"])

            new_children = files_service.create_new_children(
                file_id,
                args["output_type_id"],
                size=args["size"],
                path=args["path"],
                render_info=args["render_info"],
                file_status_id=args["file_status_id"],
                temporal_entity_id=args["temporal_entity_id"])
        except EntryAlreadyExistsException:
            return {"error": "The given children file already exists."}, 400

        return new_children, 201
예제 #5
0
def get_working_file_name(task,
                          mode="working",
                          software=None,
                          output_type=None,
                          name="",
                          revision=1):
    entity = entities_service.get_entity(task["entity_id"])
    project = get_project(entity)
    tree = get_tree_from_project(project)

    file_name = get_file_name_root(
        tree,
        mode,
        entity=entity,
        task=task,
        software=software,
        name=name,
        revision=revision,
    )

    return u"%s" % file_name
예제 #6
0
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        asset_instance = assets_service.get_asset_instance(asset_instance_id)
        asset = entities_service.get_entity(asset_instance["asset_id"])
        output_type = files_service.get_output_type(args["output_type_id"])
        task_type = tasks_service.get_task_type(args["task_type_id"])
        if not permissions.has_manager_permissions():
            user_service.check_has_task_related(asset["project_id"])

        next_revision_number = \
            files_service.get_next_output_file_revision(
                asset["id"],
                output_type["id"],
                task_type["id"],
                args["name"],
                asset_instance_id=asset_instance["id"],
                temporal_entity_id=temporal_entity_id
            )

        return {"next_revision": next_revision_number}, 200
예제 #7
0
파일: tasks_service.py 프로젝트: cgwire/zou
def get_full_task(task_id):
    task = get_task_with_relations(task_id)
    task_type = get_task_type(task["task_type_id"])
    project = projects_service.get_project(task["project_id"])
    task_status = get_task_status(task["task_status_id"])
    entity = entities_service.get_entity(task["entity_id"])
    entity_type = entities_service.get_entity_type(entity["entity_type_id"])
    assignees = [
        persons_service.get_person(assignee_id)
        for assignee_id in task["assignees"]
    ]

    task.update({
        "entity": entity,
        "task_type": task_type,
        "task_status": task_status,
        "project": project,
        "entity_type": entity_type,
        "persons": assignees,
        "type": "Task",
    })

    try:
        assigner = persons_service.get_person(task["assigner_id"])
        task["assigner"] = assigner
    except PersonNotFoundException:
        pass

    if entity["parent_id"] is not None:
        if entity_type["name"] == "Edit":
            episode_id = entity["parent_id"]
        else:
            sequence = shots_service.get_sequence(entity["parent_id"])
            task["sequence"] = sequence
            episode_id = sequence["parent_id"]
        if episode_id is not None:
            episode = shots_service.get_episode(episode_id)
            task["episode"] = episode

    return task
예제 #8
0
파일: resources.py 프로젝트: tokejepsen/zou
    def get(self, task_id):
        task = tasks_service.get_task(task_id)
        if not permissions.has_manager_permissions():
            user_service.check_has_task_related(task["project_id"])

        task_type = tasks_service.get_task_type(task["task_type_id"])
        project = projects_service.get_project(task["project_id"])
        task_status = tasks_service.get_task_status(task["task_status_id"])
        entity = entities_service.get_entity(task["entity_id"])
        entity_type = entities_service.get_entity_type(
            entity["entity_type_id"])
        assignees = []
        for assignee_id in task["assignees"]:
            assignees.append(persons_service.get_person(assignee_id))

        task.update({
            "entity": entity,
            "task_type": task_type,
            "task_status": task_status,
            "project": project,
            "entity_type": entity_type,
            "persons": assignees,
            "type": "Task"
        })

        try:
            assigner = persons_service.get_person(task["assigner_id"])
            task["assigner"] = assigner
        except PersonNotFoundException:
            pass

        if entity["parent_id"] is not None:
            sequence = shots_service.get_sequence(entity["parent_id"])
            task["sequence"] = sequence
            if sequence["parent_id"] is not None:
                episode = shots_service.get_episode(sequence["parent_id"])
                task["episode"] = episode

        return task, 200
예제 #9
0
def get_instance_folder_path(
    asset_instance,
    temporal_entity,
    output_type=None,
    task_type=None,
    name="name",
    mode="output",
    representation="",
    revision=1,
    sep=os.sep,
):
    asset = entities_service.get_entity(asset_instance["asset_id"])
    project = get_project(temporal_entity)
    tree = get_tree_from_project(project)
    root_path = get_root_path(tree, mode, sep)
    style = tree[mode]["folder_path"].get("style", "")

    folder_template = get_folder_path_template(
        tree,
        mode,
        asset_instance
    )

    folder_path = update_variable(
        folder_template,
        entity=temporal_entity,
        software=None,
        output_type=output_type,
        name=name,
        style=style,
        asset_instance=asset_instance,
        task_type=task_type,
        revision=revision,
        representation=representation,
        asset=asset
    )
    folder_path = change_folder_path_separators(folder_path, sep)

    return join_path(root_path, folder_path, "")
예제 #10
0
파일: resources.py 프로젝트: cgwire/zou
 def get(self, entity_id):
     """
     Retrieve all previews related to a given entity.
     ---
     tags:
     - Playlists
     description: It sends them as a dict. 
                  Keys are related task type ids and values are arrays of preview for this task type.
     parameters:
       - in: path
         name: entity_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description:  All previews related to given entity
     """
     entity = entities_service.get_entity(entity_id)
     user_service.check_project_access(entity["project_id"])
     return playlists_service.get_preview_files_for_entity(entity_id)
예제 #11
0
    def get(self, entity_id):
        entity = entities_service.get_entity(entity_id)
        user_service.check_project_access(entity["project_id"])

        task_type_id = request.args.get("task_type_id")
        output_type_id = request.args.get("output_type_id")
        name = request.args.get("name")
        representation = request.args.get("representation")
        file_status_id = request.args.get("file_status_id")
        created_at_since = request.args.get("created_at_since")
        person_id = request.args.get("person_id")

        return files_service.get_output_files_for_entity(
            entity["id"],
            task_type_id=task_type_id,
            output_type_id=output_type_id,
            name=name,
            representation=representation,
            file_status_id=file_status_id,
            created_at_since=created_at_since,
            person_id=person_id,
        )
예제 #12
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:
        _create_episode_casting_link(entity, asset_id, 1, label)
        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
예제 #13
0
def get_working_folder_path(task,
                            mode="working",
                            software=None,
                            output_type=None,
                            name="",
                            revision=1,
                            sep=os.sep):
    entity = entities_service.get_entity(task["entity_id"])
    project = get_project(entity)
    tree = get_tree_from_project(project)
    root_path = get_root_path(tree, mode, sep)
    style = tree[mode]["folder_path"].get("style", "")

    folder_template = get_folder_path_template(tree, mode, entity)
    folder_path = update_variable(folder_template,
                                  entity=entity,
                                  task=task,
                                  software=software,
                                  name=name,
                                  revision=revision,
                                  style=style)
    folder_path = change_folder_path_separators(folder_path, sep)

    return join_path(root_path, folder_path, "")
예제 #14
0
 def test_get_entity(self):
     entity = entities_service.get_entity(self.asset.id)
     self.assertEquals(entity, self.asset.serialize())
예제 #15
0
 def check_read_permissions(self, instance):
     entity = entities_service.get_entity(instance["entity_id"])
     return user_service.check_project_access(entity["project_id"])
예제 #16
0
 def get(self, entity_id):
     entity = entities_service.get_entity(entity_id)
     user_service.check_project_access(entity["project_id"])
     return files_service.get_output_types_for_entity(entity_id)
예제 #17
0
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])
            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"]
                )
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                working_file_id = None

            asset_instance = assets_service.get_asset_instance(
                asset_instance_id
            )
            temporal_entity = entities_service.get_entity(temporal_entity_id)

            entity = assets_service.get_asset(asset_instance["asset_id"])
            user_service.check_project_access(entity["project_id"])

            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file = files_service.create_new_output_revision(
                asset_instance["asset_id"],
                working_file_id,
                output_type["id"],
                person["id"],
                task_type["id"],
                asset_instance_id=asset_instance["id"],
                temporal_entity_id=temporal_entity_id,
                revision=revision,
                name=args["name"],
                representation=args["representation"],
                comment=args["comment"],
                nb_elements=int(args["nb_elements"]),
                extension=args["extension"],
            )

            output_file_dict = self.add_path_info(
                output_file,
                "output",
                asset_instance,
                temporal_entity,
                output_type,
                task_type=task_type,
                name=args["name"],
                extension=args["extension"],
                representation=args["representation"],
                nb_elements=int(args["nb_elements"]),
                separator=args["sep"],
            )
        except OutputTypeNotFoundException:
            return {"message": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"message": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"message": "The given output file already exists."}, 400

        return output_file_dict, 201
예제 #18
0
파일: resources.py 프로젝트: withgame/zou
 def get(self, asset_instance_id, temporal_entity_id):
     asset_instance = assets_service.get_asset_instance(asset_instance_id)
     entity = entities_service.get_entity(asset_instance["asset_id"])
     user_service.check_project_access(entity["project_id"])
     return files_service.get_output_types_for_instance(
         asset_instance_id, temporal_entity_id)
예제 #19
0
파일: resources.py 프로젝트: NeroSouza/zou
 def get(self, entity_id):
     entity = entities_service.get_entity(entity_id)
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(entity["project_id"])
     return files_service.get_last_output_files_for_entity(entity["id"])
예제 #20
0
def create_new_output_revision(entity_id,
                               working_file_id,
                               output_type_id,
                               person_id,
                               task_type_id,
                               revision=0,
                               representation="",
                               name="main",
                               comment="",
                               extension="",
                               path="",
                               size=None,
                               render_info=None,
                               nb_elements=1,
                               asset_instance_id=None,
                               temporal_entity_id=None,
                               file_status_id=None):
    """
    Create a new ouput file for given entity. Output type, task type, author
    and source file are required.

    The revision is set as next revision available but it can be forced.
    An extension and a name can be set too.

    An asset instance can be given too. In that case, the output file is
    linked to the asset instance.

    The `temporal_entity_id` concerns only asset instance output files. It is
    here to describe if the output is generated in the context of a shot or in
    the context of a scene.
    """

    if revision < 1:
        try:
            output_file = get_last_output_revision(
                entity_id,
                output_type_id,
                task_type_id,
                name=name,
                asset_instance_id=asset_instance_id,
                temporal_entity_id=temporal_entity_id,
            )

            revision = output_file["revision"] + 1
        except NoOutputFileException:
            revision = 1

    file_status_id = file_status_id or get_default_status()["id"]

    try:
        output_file = OutputFile.get_by(
            name=name,
            entity_id=entity_id,
            asset_instance_id=asset_instance_id,
            output_type_id=output_type_id,
            task_type_id=task_type_id,
            temporal_entity_id=temporal_entity_id,
            representation=representation,
            revision=revision,
        )

        if output_file is None:
            output_file = OutputFile.create(
                name=name,
                comment=comment,
                extension=extension,
                path=path,
                size=size,
                representation=representation,
                render_info=render_info,
                revision=revision,
                entity_id=entity_id,
                asset_instance_id=asset_instance_id,
                person_id=person_id,
                source_file_id=working_file_id,
                output_type_id=output_type_id,
                file_status_id=file_status_id,
                task_type_id=task_type_id,
                nb_elements=nb_elements,
                temporal_entity_id=temporal_entity_id,
            )
            entity = entities_service.get_entity(entity_id)
            events.emit("output-file:new", {"output_file_id": output_file.id},
                        project_id=entity["project_id"])
        else:
            raise EntryAlreadyExistsException

    except IntegrityError:
        raise EntryAlreadyExistsException

    return output_file.serialize()
예제 #21
0
파일: resources.py 프로젝트: dsparrow27/zou
 def get(self, entity_id, task_type_id):
     entity = entities_service.get_entity(entity_id)
     user_service.check_project_access(entity["project_id"])
     return tasks_service.get_tasks_for_entity_and_task_type(
         entity_id, task_type_id)
예제 #22
0
 def emit_event(self, event_type, entry):
     entity = entities_service.get_entity(entry["entity_in_id"])
     project_id = entity["project_id"]
     events.emit("entity-link:%s" % event_type, project_id=project_id)
예제 #23
0
파일: resources.py 프로젝트: cgwire/zou
 def get(self, entity_id):
     entity = entities_service.get_entity(entity_id)
     user_service.check_project_access(entity["project_id"])
     return preview_files_service.get_preview_files_for_entity(entity_id)
예제 #24
0
파일: resources.py 프로젝트: cgwire/zou
 def get(self, entity_id):
     entity = entities_service.get_entity(entity_id)
     user_service.check_project_access(entity["project_id"])
     return time_spents_service.get_time_spents_for_entity(entity_id)
예제 #25
0
파일: resources.py 프로젝트: NeroSouza/zou
 def get(self, entity_id, task_type_id):
     entity = entities_service.get_entity(entity_id)
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(entity["project_id"])
     return tasks_service.get_tasks_for_entity_and_task_type(
         entity_id, task_type_id)