Ejemplo n.º 1
0
def create_new_working_revision(task_id,
                                person_id,
                                software_id,
                                name="main",
                                path="",
                                comment="",
                                revision=0):
    """
    Create a new working file revision for given task. An author (user) and
    a software are required.
    """
    task = Task.get(task_id)
    if revision == 0:
        revision = get_next_working_revision(task_id, name)

    try:
        working_file = WorkingFile.create(comment=comment,
                                          name=name,
                                          revision=revision,
                                          path=path,
                                          task_id=task.id,
                                          software_id=software_id,
                                          entity_id=task.entity_id,
                                          person_id=person_id)
        events.emit("working_file:new", {"working_file_id": working_file.id})
    except IntegrityError:
        raise EntryAlreadyExistsException

    return working_file.serialize()
Ejemplo n.º 2
0
 def generate_fixture_shot_working_file(self):
     self.working_file = WorkingFile.create(name="main",
                                            comment="",
                                            revision=1,
                                            task_id=self.shot_task.id,
                                            entity_id=self.shot.id,
                                            person_id=self.person.id,
                                            software_id=self.software.id)
Ejemplo n.º 3
0
 def generate_fixture_working_file(self, name="main", revision=1):
     self.working_file = WorkingFile.create(name=name,
                                            comment="",
                                            revision=revision,
                                            task_id=self.task.id,
                                            entity_id=self.asset.id,
                                            person_id=self.person.id,
                                            software_id=self.software.id)
     return self.working_file
Ejemplo n.º 4
0
def create_new_working_revision(
    person_id,
    software_id,
    entity_id=None,
    task_id=None,
    name="main",
    path="",
    comment="",
    revision=0,
):
    """
    Create a new working file revision for given task. An author (user) and
    a software are required.
    """

    if task_id:
        task = Task.get(task_id)
        entity_id = task.entity_id

    if revision == 0:
        revision = get_next_working_revision(name, task_id=task_id, entity_id=entity_id)

    if path:
        previous_working_file = get_working_file_by_path(path)
        if previous_working_file:
            return previous_working_file.serialize()

    try:
        working_file = WorkingFile.create(
            comment=comment,
            name=name,
            revision=revision,
            path=path,
            task_id=task_id,
            software_id=software_id,
            entity_id=entity_id,
            person_id=person_id,
        )
        events.emit(
            "working_file:new", 
            {"working_file_id": working_file.id},
            project_id=str(task.project_id)
        )
    except IntegrityError:
        raise EntryAlreadyExistsException

    return working_file.serialize()