Exemple #1
0
class WorkingFile(db.Model, BaseMixin, SerializerMixin):
    shotgun_id = db.Column(db.Integer())

    name = db.Column(db.String(250))
    description = db.Column(db.String(200))
    comment = db.Column(db.Text())
    revision = db.Column(db.Integer())
    size = db.Column(db.Integer())
    checksum = db.Column(db.Integer())

    task_id = db.Column(UUIDType(binary=False), db.ForeignKey("task.id"))
    entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
    person_id = \
        db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))

    __table_args__ = (
        db.UniqueConstraint(
            "name",
            "task_id",
            "entity_id",
            "revision",
            name="working_file_uc"
        ),
    )

    def __repr__(self):
        return "<WorkingFile %s>" % self.id
Exemple #2
0
class WorkingFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes the file related to the work done on a given task. It is
    used as source of output files published for a given entity.
    """
    shotgun_id = db.Column(db.Integer(), index=True)

    name = db.Column(db.String(250))
    description = db.Column(db.String(200))
    comment = db.Column(db.Text())
    revision = db.Column(db.Integer())
    size = db.Column(db.Integer())
    checksum = db.Column(db.Integer())
    path = db.Column(db.String(400))

    task_id = db.Column(UUIDType(binary=False),
                        db.ForeignKey("task.id"),
                        index=True)
    entity_id = db.Column(UUIDType(binary=False),
                          db.ForeignKey("entity.id"),
                          index=True)
    person_id = \
        db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
    software_id = \
        db.Column(UUIDType(binary=False), db.ForeignKey("software.id"))
    outputs = relationship("OutputFile", back_populates="source_file")

    __table_args__ = (db.UniqueConstraint("name",
                                          "task_id",
                                          "entity_id",
                                          "revision",
                                          name="working_file_uc"), )

    def __repr__(self):
        return "<WorkingFile %s>" % self.id
Exemple #3
0
class OutputFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describe a file generated from a CG artist scene. It's the result of a
    publication.
    It is linked to a working file, an entity and a task type.
    """
    shotgun_id = db.Column(db.Integer())

    name = db.Column(db.String(250), nullable=False)
    extension = db.Column(db.String(10))
    revision = db.Column(db.Integer(), nullable=False)
    representation = db.Column(db.String(20), index=True)
    nb_elements = db.Column(db.Integer(), default=1)

    path = db.Column(db.String(400))

    description = db.Column(db.Text())
    comment = db.Column(db.Text())
    size = db.Column(db.Integer())
    checksum = db.Column(db.String(32))
    source = db.Column(db.String(40))

    canceled = db.Column(db.Boolean(), default=False, nullable=False)

    file_status_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey("file_status.id"),
                               nullable=False)
    entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
    asset_instance_id = db.Column(UUIDType(binary=False),
                                  db.ForeignKey("asset_instance.id"),
                                  index=True)
    output_type_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey("output_type.id"),
                               index=True)
    task_type_id = db.Column(UUIDType(binary=False),
                             db.ForeignKey("task_type.id"),
                             index=True)
    person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
    source_file_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey("working_file.id"),
    )
    source_file = relationship("WorkingFile", back_populates="outputs")
    temporal_entity_id = db.Column(UUIDType(binary=False),
                                   db.ForeignKey("entity.id"),
                                   default=None,
                                   nullable=True)

    __table_args__ = (db.UniqueConstraint("name",
                                          "entity_id",
                                          "asset_instance_id",
                                          "output_type_id",
                                          "task_type_id",
                                          "temporal_entity_id",
                                          "representation",
                                          "revision",
                                          name="output_file_uc"), )

    def __repr__(self):
        return "<OutputFile %s>" % self.id
Exemple #4
0
class PreviewFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes a file which is aimed at being reviewed. It is not a publication
    neither a working file.
    """

    name = db.Column(db.String(250))
    original_name = db.Column(db.String(250))
    revision = db.Column(db.Integer(), default=1)
    position = db.Column(db.Integer(), default=1)
    extension = db.Column(db.String(6))
    description = db.Column(db.Text())
    path = db.Column(db.String(400))
    source = db.Column(db.String(40))
    file_size = db.Column(db.Integer(), default=0)
    status = db.Column(ChoiceType(STATUSES), default="processing")
    validation_status = db.Column(
        ChoiceType(VALIDATION_STATUSES), default="neutral"
    )
    annotations = db.Column(JSONB)

    task_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("task.id"), index=True
    )
    person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
    source_file_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("output_file.id")
    )

    __table_args__ = (
        db.UniqueConstraint("name", "task_id", "revision", name="preview_uc"),
    )

    shotgun_id = db.Column(db.Integer, unique=True)

    is_movie = db.Column(db.Boolean, default=False)  # deprecated
    url = db.Column(db.String(600))  # deprecated
    uploaded_movie_url = db.Column(db.String(600))  # deprecated
    uploaded_movie_name = db.Column(db.String(150))  # deprecated

    def __repr__(self):
        return "<PreviewFile %s>" % self.id

    @classmethod
    def create_from_import(cls, data):
        del data["type"]
        if "comments" in data:
            del data["comments"]
        previous_data = cls.get(data["id"])
        if "status" not in data or data["status"] == None:
            data["status"] = "ready"
        if previous_data is None:
            return (cls.create(**data), False)
        else:
            previous_data.update(data)
            return (previous_data, True)
Exemple #5
0
class AttachmentFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes a file which is attached to a comment.
    """

    name = db.Column(db.String(250))
    size = db.Column(db.Integer(), default=1)
    extension = db.Column(db.String(6))
    mimetype = db.Column(db.String(255))
    comment_id = db.Column(UUIDType(binary=False),
                           db.ForeignKey("comment.id"),
                           index=True)

    __table_args__ = (db.UniqueConstraint("name",
                                          "comment_id",
                                          name="attachment_uc"), )

    def __repr__(self):
        return "<AttachmentFile %s>" % self.id

    def present(self):
        return {
            "id": str(self.id),
            "name": self.name,
            "extension": self.extension,
            "size": self.size,
        }
Exemple #6
0
class PreviewFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes a file which is aimed at being reviewed. It is not a publication
    neither a working file.
    """
    name = db.Column(db.String(250))
    revision = db.Column(db.Integer(), default=1)
    description = db.Column(db.Text())
    path = db.Column(db.String(400))

    source = db.Column(db.String(40))
    shotgun_id = db.Column(db.Integer, unique=True)

    is_movie = db.Column(db.Boolean, default=False)

    url = db.Column(db.String(600))
    uploaded_movie_url = db.Column(db.String(600))
    uploaded_movie_name = db.Column(db.String(150))

    task_id = db.Column(UUIDType(binary=False),
                        db.ForeignKey("task.id"),
                        index=True)
    person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))

    source_file_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey("output_file.id"))

    __table_args__ = (db.UniqueConstraint("name",
                                          "task_id",
                                          "revision",
                                          name="preview_uc"), )

    def __repr__(self):
        return "<PreviewFile %s>" % self.id
Exemple #7
0
class Organisation(db.Model, BaseMixin, SerializerMixin):
    """
    Model to represent current organisation settings.
    """

    name = db.Column(db.String(80), unique=True, nullable=False)
    hours_by_day = db.Column(db.Integer(), default=8, nullable=False)
    has_avatar = db.Column(db.Boolean(), default=False)
    use_original_file_name = db.Column(db.Boolean(), default=False)
    timesheets_locked = db.Column(db.Boolean(), default=False)
    hd_by_default = db.Column(db.Boolean(), default=False)
    chat_token_slack = db.Column(db.String(80), default="")

    def present(self):
        return fields.serialize_dict(
            {
                "id": self.id,
                "chat_token_slack": self.chat_token_slack,
                "name": self.name,
                "has_avatar": self.has_avatar,
                "hours_by_day": self.hours_by_day,
                "hd_by_default": self.hd_by_default,
                "use_original_file_name": self.use_original_file_name,
                "timesheets_locked": self.timesheets_locked,
            }
        )
Exemple #8
0
class AssetInstance(db.Model, BaseMixin, SerializerMixin):
    """
    An asset instance is the representation of an asset in a given shot or
    layout scene. It is useful for complex scenes where an asset needs extra
    treatments only related to the given shot or layout scene.
    An asset can have multiple instances in a scene (ex: a sword in a battle
    field).
    """
    asset_id = db.Column(UUIDType(binary=False),
                         db.ForeignKey('entity.id'),
                         nullable=False)
    entity_id = db.Column(UUIDType(binary=False),
                          db.ForeignKey('entity.id'),
                          nullable=False)
    entity_type_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey('entity_type.id'),
                               nullable=False)
    number = db.Column(db.Integer())
    description = db.Column(db.String(200))
    data = db.Column(JSONB)

    __table_args__ = (db.UniqueConstraint('asset_id',
                                          'entity_id',
                                          'number',
                                          name='asset_instance_uc'), )

    def __repr__(self):
        return "<AssetInstance %s>" % self.id
Exemple #9
0
class DependentFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describe a file generated from a CG artist scene. 
    It aims to know the dependencies of an outputfile.
    """
    __tablename__ = "dependent_file"
    source_output_file_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("output_file.id"), nullable=True
    )
    size = db.Column(db.Integer())
    checksum = db.Column(db.String(32))
    extension = db.Column(db.String(10))
    path = db.Column(db.String(400), unique=True)
    used_by = relationship(
        "OutputFile", secondary=dependent_table, back_populates="dependent_files"
    )
    project_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("project.id")
    )
    temporal_entity_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey("entity.id"),
        default=None,
        nullable=True,
    )

    def __repr__(self):
        return "<DependentFile %s>" % self.id
Exemple #10
0
class Snapshot(db.Model, BaseMixin, SerializerMixin):
    revision = db.Column(db.Integer())
    working_file_id = \
        db.Column(UUIDType(binary=False), db.ForeignKey("working_file_id"))

    __table_args__ = (
        db.UniqueConstraint(
            "revision",
            "working_file_id",
            name="snapshot_uc"
        ),
    )
Exemple #11
0
class AssetInstance(db.Model, BaseMixin, SerializerMixin):
    """
    An asset instance is the representation of an asset in a given shot or
    layout scene. It is useful for complex scenes where an asset needs extra
    treatments only related to the given shot or layout scene.
    An asset can have multiple instances in a scene or in a shot (ex: a sword in
    a battle field).
    """
    asset_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey('entity.id'),
        nullable=False,
        index=True
    )
    name = db.Column(db.String(80))
    number = db.Column(db.Integer())
    description = db.Column(db.String(200))
    active = db.Column(db.Boolean(), default=True)
    data = db.Column(JSONB)

    scene_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey('entity.id'),
        index=True
    )

    __table_args__ = (
        db.UniqueConstraint(
            'asset_id',
            'scene_id',
            'number',
            name='asset_instance_uc'
        ),
        db.UniqueConstraint(
            'scene_id',
            'name',
            name='asset_instance_name_uc'
        )
    )

    # Do not use these column. They are deprecated and will be dropped in
    # upcoming version
    entity_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey('entity.id'),
    )
    entity_type_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey('entity_type.id')
    )

    def __repr__(self):
        return "<AssetInstance %s>" % self.id
Exemple #12
0
class OutputFile(db.Model, BaseMixin, SerializerMixin):
    shotgun_id = db.Column(db.Integer())

    name = db.Column(db.String(250))
    description = db.Column(db.Text())
    comment = db.Column(db.Text())
    revision = db.Column(db.Integer())
    size = db.Column(db.Integer())
    checksum = db.Column(db.Integer())
    source = db.Column(db.String(40))

    uploaded_movie_url = db.Column(db.String(600))
    uploaded_movie_name = db.Column(db.String(150))

    file_status_id = \
        db.Column(
            UUIDType(binary=False),
            db.ForeignKey("file_status.id"),
            nullable=False
        )

    task_id = db.Column(UUIDType(binary=False), db.ForeignKey("task.id"))
    entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
    person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
    source_file_id = \
        db.Column(
            UUIDType(binary=False),
            db.ForeignKey("working_file.id")
        )

    __table_args__ = (db.UniqueConstraint("name",
                                          "task_id",
                                          "entity_id",
                                          "revision",
                                          name="output_file_uc"), )

    def __repr__(self):
        return "<OutputFile %s>" % self.id
Exemple #13
0
class Organisation(db.Model, BaseMixin, SerializerMixin):
    """
    Model to represent current organisation settings.
    """
    name = db.Column(db.String(80), unique=True, nullable=False)
    hours_by_day = db.Column(db.Integer(), default=8, nullable=False)
    has_avatar = db.Column(db.Boolean(), default=False)

    def present(self):
        return fields.serialize_dict({
            "id": self.id,
            "name": self.name,
            "has_avatar": self.has_avatar,
            "hours_by_day": self.hours_by_day
        })
Exemple #14
0
class AttachmentFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes a file which is attached to a comment.
    """

    name = db.Column(db.String(250))
    size = db.Column(db.Integer(), default=1)
    extension = db.Column(db.String(6))
    mimetype = db.Column(db.String(255))
    comment_id = db.Column(UUIDType(binary=False),
                           db.ForeignKey("comment.id"),
                           index=True)

    __table_args__ = (db.UniqueConstraint("name",
                                          "comment_id",
                                          name="attachment_uc"), )

    def __repr__(self):
        return "<AttachmentFile %s>" % self.id

    def present(self):
        return {
            "id": str(self.id),
            "name": self.name,
            "extension": self.extension,
            "size": self.size,
        }

    @classmethod
    def create_from_import(cls, data):
        data.pop("type", None)
        data.pop("comment", None)
        previous_data = cls.get(data["id"])
        if previous_data is None:
            return cls.create(**data)
        else:
            previous_data.update(data)
            return previous_data
Exemple #15
0
class ChildrenFile(db.Model, BaseMixin, SerializerMixin):
    """
    Describes the generated file based on a output_file, for example a Review/ Proxy.
    """
    __tablename__ = "children_file"

    size = db.Column(db.Integer())
    path = db.Column(db.String(400), unique=True)
    parent_file_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey('output_file.id'))
    output_type_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey("output_type.id"),
                               index=True)
    output_type = relationship("OutputType", lazy="joined")
    file_status_id = db.Column(UUIDType(binary=False),
                               db.ForeignKey("file_status.id"),
                               nullable=False)
    render_info = db.Column(db.String(200))
    file_status = relationship("FileStatus", lazy="joined")
    render_info = db.Column(db.String(200))
    data = db.Column(JSONB)
    temporal_entity_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey("entity.id"),
        default=None,
        nullable=True,
    )

    __table_args__ = (db.UniqueConstraint(
        "parent_file_id",
        "output_type_id",
        name="children_file_uc",
    ), )

    def __repr__(self):
        return "<ChildrenFile %s>" % self.id
Exemple #16
0
class OutputFile(db.Model, BaseMixin, OutputFileSerializer):
    """
    Describe a file generated from a CG artist scene. It's the result of a
    publication.
    It is linked to a working/ children/ dependent file, an entity and a task type.
    """
    __tablename__ = "output_file"

    shotgun_id = db.Column(db.String(50))

    name = db.Column(db.String(250), nullable=False)
    canceled = db.Column(db.Boolean(), default=False, nullable=False) # surement une forme d'"omit"
    size = db.Column(db.Integer())
    checksum = db.Column(db.String(32))
    description = db.Column(db.Text())
    comment = db.Column(db.Text())
    extension = db.Column(db.String(10))
    revision = db.Column(db.Integer(), nullable=False) # version
    representation = db.Column(db.String(20), index=True) # une manière de regrouper (ex: par extension)
    nb_elements = db.Column(db.Integer(), default=1) # à refaire, pas de start-end
    source = db.Column(db.String(40)) # permet de dire d'où ça vient (ex: muster)
    path = db.Column(db.String(400))
    data = db.Column(JSONB)

    file_status_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("file_status.id"), nullable=False
    )
    entity_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"))
    asset_instance_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("asset_instance.id"), index=True
    )
    output_type_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("output_type.id"), index=True
    )
    task_type_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("task_type.id"), index=True
    )
    person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"))
    render_info = db.Column(db.String(200))
    source_file_id = db.Column(
        UUIDType(binary=False), db.ForeignKey("working_file.id")
    )
    render_info = db.Column(db.String(200))
    source_file = relationship(
        "WorkingFile", 
        lazy="joined", 
        back_populates="outputs"
    )
    children_files = relationship(
        "ChildrenFile", 
        lazy="joined", 
        backref=backref("parent_file", cascade="all, delete")
    )
    # TODO: by default not serialize it
    dependent_files = relationship(
        "DependentFile",
        secondary=dependent_table,
        back_populates="used_by"
    )
    temporal_entity_id = db.Column(
        UUIDType(binary=False),
        db.ForeignKey("entity.id"),
        default=None,
        nullable=True,
    )

    __table_args__ = (
        db.UniqueConstraint(
            "name",
            "entity_id",
            "asset_instance_id",
            "output_type_id",
            "task_type_id",
            "temporal_entity_id",
            "representation",
            "revision",
            name="output_file_uc",
        ),
    )

    def __repr__(self):
        return "<OutputFile %s>" % self.id