class Subscription(db.Model, BaseMixin, SerializerMixin): """ Allow to subscribe to an entity """ person_id = db.Column( UUIDType(binary=False), db.ForeignKey("person.id"), nullable=False, index=True, ) 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 ) task_type_id = db.Column( UUIDType(binary=False), db.ForeignKey("task_type.id"), index=True ) __table_args__ = ( db.UniqueConstraint( "person_id", "task_id", name="subscription_task_uc" ), db.UniqueConstraint( "person_id", "task_type_id", "entity_id", name="subscription_entity_uc", ), )
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
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
class MetadataDescriptor(db.Model, BaseMixin, SerializerMixin): """ This models allow to identify which metadata are available for a given project and a given entity type. """ project_id = db.Column( UUIDType(binary=False), db.ForeignKey("project.id"), nullable=False, index=True, ) entity_type = db.Column(db.String(60), nullable=False, index=True) name = db.Column(db.String(120), nullable=False) field_name = db.Column(db.String(120), nullable=False) choices = db.Column(JSONB) for_client = db.Column(db.Boolean(), default=False, index=True) __table_args__ = (db.UniqueConstraint("project_id", "entity_type", "name", name="metadata_descriptor_uc"), ) def __repr__(self): return "<MetadataDescriptor %s>" % self.id
class Notification(db.Model, BaseMixin, SerializerMixin): """ A notification is stored each time a comment is posted. """ read = db.Column(db.Boolean, nullable=False, default=False) change = db.Column(db.Boolean, nullable=False, default=False) person_id = db.Column(UUIDType(binary=False), db.ForeignKey('person.id'), nullable=False, index=True) author_id = db.Column(UUIDType(binary=False), db.ForeignKey('person.id'), nullable=False, index=True) comment_id = db.Column(UUIDType(binary=False), db.ForeignKey('comment.id'), nullable=False, index=True) task_id = db.Column(UUIDType(binary=False), db.ForeignKey('task.id'), nullable=False, index=True) __table_args__ = (db.UniqueConstraint('person_id', 'author_id', 'comment_id', name='notification_uc'), )
class Playlist(db.Model, BaseMixin, SerializerMixin): """ Describes a playlist. The goal is to review a set of shipped materials. """ name = db.Column(db.String(80), nullable=False) shots = db.Column(JSONB) project_id = db.Column(UUIDType(binary=False), db.ForeignKey("project.id"), index=True) episode_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"), index=True) for_client = db.Column(db.Boolean(), default=False, index=True) for_entity = db.Column(db.String(10), default="shot", index=True) is_for_all = db.Column(db.Boolean, default=False) build_jobs = relationship("BuildJob") __table_args__ = (db.UniqueConstraint("name", "project_id", "episode_id", name="playlist_uc"), ) @classmethod def create_from_import(cls, data): del data["type"] del data["build_jobs"] previous_data = cls.get(data["id"]) if previous_data is None: return cls.create(**data) else: previous_data.update(data) return previous_data
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
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
class Task(db.Model, BaseMixin, SerializerMixin): """ Describes a task done by a CG artist on an entity of the CG production. The task has a state and assigned to people. It handles notion of time like duration, start date and end date. """ name = db.Column(db.String(80), nullable=False) description = db.Column(db.String(200)) priority = db.Column(db.Integer, default=0) duration = db.Column(db.Integer, default=0) estimation = db.Column(db.Integer, default=0) completion_rate = db.Column(db.Integer, default=0) sort_order = db.Column(db.Integer, default=0) start_date = db.Column(db.DateTime) end_date = db.Column(db.DateTime) due_date = db.Column(db.DateTime) real_start_date = db.Column(db.DateTime) shotgun_id = db.Column(db.Integer) project_id = db.Column( UUIDType(binary=False), db.ForeignKey('project.id'), index=True ) task_type_id = db.Column( UUIDType(binary=False), db.ForeignKey('task_type.id') ) task_status_id = db.Column( UUIDType(binary=False), db.ForeignKey('task_status.id') ) entity_id = db.Column( UUIDType(binary=False), db.ForeignKey('entity.id'), index=True ) assigner_id = db.Column( UUIDType(binary=False), db.ForeignKey('person.id') ) assignees = db.relationship( 'Person', secondary=association_table ) __table_args__ = ( db.UniqueConstraint( 'name', 'project_id', 'task_type_id', 'entity_id', name='task_uc' ), ) def assignees_as_string(self): return ", ".join([x.full_name() for x in self.assignees])
class Entity(db.Model, BaseMixin, SerializerMixin): id = db.Column( UUIDType(binary=False), primary_key=True, default=fields.gen_uuid ) name = db.Column(db.String(160), nullable=False) description = db.Column(db.String(300)) shotgun_id = db.Column(db.Integer) project_id = db.Column( UUIDType(binary=False), db.ForeignKey('project.id'), nullable=False) entity_type_id = db.Column( UUIDType(binary=False), db.ForeignKey('entity_type.id'), nullable=False) parent_id = db.Column( UUIDType(binary=False), db.ForeignKey('entity.id')) data = db.Column(JSONB) entities_out = db.relationship( 'Entity', secondary=entity_link, primaryjoin=(id == entity_link.c.entity_in_id), secondaryjoin=(id == entity_link.c.entity_out_id) ) __table_args__ = ( db.UniqueConstraint( 'name', 'project_id', 'entity_type_id', 'parent_id', name='entity_uc' ), )
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, }
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
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
class TaskType(db.Model, BaseMixin, SerializerMixin): """ Categorize tasks in domain areas: modeling, animation, etc. """ name = db.Column(db.String(40), nullable=False) short_name = db.Column(db.String(20)) color = db.Column(db.String(7), default="#FFFFFF") priority = db.Column(db.Integer, default=1) for_shots = db.Column(db.Boolean, default=False) for_entity = db.Column(db.String(30), default="Asset") allow_timelog = db.Column(db.Boolean, default=True) shotgun_id = db.Column(db.Integer, index=True) department_id = db.Column( UUIDType(binary=False), db.ForeignKey("department.id") ) __table_args__ = ( db.UniqueConstraint( 'name', 'for_entity', 'department_id', name='task_type_uc' ), )
class Entity(db.Model, BaseMixin, SerializerMixin): """ Base model to represent assets, shots, sequences, episodes and scenes. They have different meaning but they share the same behaviour toward tasks and files. """ id = db.Column(UUIDType(binary=False), primary_key=True, default=fields.gen_uuid) name = db.Column(db.String(160), nullable=False) code = db.Column(db.String(160)) # To store sanitized version of name description = db.Column(db.String(1200)) shotgun_id = db.Column(db.Integer) canceled = db.Column(db.Boolean, default=False) nb_frames = db.Column(db.Integer) # Specific to shots project_id = db.Column(UUIDType(binary=False), db.ForeignKey("project.id"), nullable=False, index=True) entity_type_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity_type.id"), nullable=False, index=True) parent_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id"), index=True) # sequence or episode source_id = db.Column( UUIDType(binary=False), db.ForeignKey("entity.id"), index=True, nullable=True ) # if the entity is generated from another one (like shots from scene). preview_file_id = db.Column( UUIDType(binary=False), db.ForeignKey("preview_file.id", name="fk_main_preview")) data = db.Column(JSONB) entities_out = db.relationship( "Entity", secondary="entity_link", primaryjoin=(id == EntityLink.entity_in_id), secondaryjoin=(id == EntityLink.entity_out_id), backref="entities_in") instance_casting = db.relationship("AssetInstance", secondary="asset_instance_link", backref="shots") __table_args__ = (db.UniqueConstraint("name", "project_id", "entity_type_id", "parent_id", name="entity_uc"), )
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)
class DayOff(db.Model, BaseMixin, SerializerMixin): """ Tells that someone will have a day off this day. """ date = db.Column(db.Date, nullable=False) person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"), index=True) __table_args__ = (db.UniqueConstraint("person_id", "date", name="day_off_uc"), )
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" ), )
class ProjectTaskTypeLink(db.Model, BaseMixin): __tablename__ = "project_task_type_link" project_id = db.Column(UUIDType(binary=False), db.ForeignKey("project.id"), primary_key=True) task_type_id = db.Column(UUIDType(binary=False), db.ForeignKey("task_type.id"), primary_key=True) priority = db.Column(db.Integer, default=None) __table_args__ = (db.UniqueConstraint("project_id", "task_type_id", name="project_tasktype_uc"), )
class Notification(db.Model, BaseMixin, SerializerMixin): """ A notification is stored each time a comment is posted. """ read = db.Column(db.Boolean, nullable=False, default=False) change = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(ChoiceType(TYPES)) person_id = db.Column( UUIDType(binary=False), db.ForeignKey('person.id'), nullable=False, index=True ) author_id = db.Column( UUIDType(binary=False), db.ForeignKey('person.id'), nullable=False, index=True ) comment_id = db.Column( UUIDType(binary=False), db.ForeignKey('comment.id'), nullable=True, index=True ) task_id = db.Column( UUIDType(binary=False), db.ForeignKey('task.id'), nullable=False, index=True ) __table_args__ = ( db.UniqueConstraint( 'person_id', 'author_id', 'comment_id', 'type', name='notification_uc' ), ) def serialize(self, obj_type=None): attrs = inspect(self).attrs.keys() obj_dict = { attr: serialize_value(getattr(self, attr)) for attr in attrs } obj_dict["notitfication_type"] = obj_dict["type"] obj_dict["type"] = obj_type or type(self).__name__ return obj_dict
class TaskType(db.Model, BaseMixin, SerializerMixin): name = db.Column(db.String(40), nullable=False) color = db.Column(db.String(7), default="#FFFFFF") shotgun_id = db.Column(db.Integer) department_id = \ db.Column( UUIDType(binary=False), db.ForeignKey("department.id") ) __table_args__ = (db.UniqueConstraint('name', 'department_id', name='task_type_uc'), )
class Playlist(db.Model, BaseMixin, SerializerMixin): """ Describes a playlist. The goal is to discuss around a defined set of shipped materials in a meeting. """ name = db.Column(db.String(80), nullable=False) shots = db.Column(JSONB) project_id = db.Column(UUIDType(binary=False), db.ForeignKey('project.id')) episode_id = db.Column(UUIDType(binary=False), db.ForeignKey('entity.id')) __table_args__ = (db.UniqueConstraint('name', 'project_id', 'episode_id', name='playlist_uc'), )
class Entity(db.Model, BaseMixin, SerializerMixin): """ Base model to represent assets, shots, sequences, episodes and scenes. They have different meaning but they share the same behaviour toward tasks and files. """ id = db.Column( UUIDType(binary=False), primary_key=True, default=fields.gen_uuid ) name = db.Column(db.String(160), nullable=False) description = db.Column(db.String(600)) shotgun_id = db.Column(db.Integer) canceled = db.Column(db.Boolean, default=False) project_id = db.Column( UUIDType(binary=False), db.ForeignKey('project.id'), nullable=False) entity_type_id = db.Column( UUIDType(binary=False), db.ForeignKey('entity_type.id'), nullable=False) parent_id = db.Column( UUIDType(binary=False), db.ForeignKey('entity.id')) preview_file_id = db.Column( UUIDType(binary=False), db.ForeignKey('preview_file.id', name="fk_main_preview") ) data = db.Column(JSONB) entities_out = db.relationship( 'Entity', secondary='entity_link', primaryjoin=(id == EntityLink.entity_in_id), secondaryjoin=(id == EntityLink.entity_out_id), backref="entities_in" ) __table_args__ = ( db.UniqueConstraint( 'name', 'project_id', 'entity_type_id', 'parent_id', name='entity_uc' ), )
class DayWorked(db.Model, BaseMixin, SerializerMixin): """ Describes the day worked by a person. """ date = db.Column(db.Date, nullable=False) person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"), index=True) work_duration = db.Column(db.Float, default=1) variable_time = db.Column(db.Integer, default=0) justification = db.Column(db.Text()) __table_args__ = (db.UniqueConstraint("person_id", "date", name="day_worked_uc"), )
class TimeSpent(db.Model, BaseMixin, SerializerMixin): """ Describes the time spent by someone on a task. """ duration = db.Column(db.Integer, nullable=False) date = db.Column(db.Date, nullable=False) task_id = db.Column(UUIDType(binary=False), db.ForeignKey("task.id"), index=True) person_id = db.Column(UUIDType(binary=False), db.ForeignKey("person.id"), index=True) __table_args__ = (db.UniqueConstraint("person_id", "task_id", "date", name="time_spent_uc"), )
class TimeSpent(db.Model, BaseMixin, SerializerMixin): """ Describes the time spent by someone on a task. """ duration = db.Column(db.Integer, nullable=False) date = db.Column(db.Date, nullable=False) task_id = \ db.Column(UUIDType(binary=False), db.ForeignKey('task.id')) person_id = \ db.Column(UUIDType(binary=False), db.ForeignKey('person.id')) __table_args__ = ( db.UniqueConstraint( 'person_id', 'task_id', 'date', name='time_spent_uc' ), )
class ScheduleItem(db.Model, BaseMixin, SerializerMixin): """ Allow to set a start date and an end date for a task type and a project. This information allows to build a schedule for the project. """ start_date = db.Column(db.Date()) end_date = db.Column(db.Date()) man_days = db.Column(db.Integer) project_id = db.Column( UUIDType(binary=False), db.ForeignKey("project.id"), index=True ) task_type_id = db.Column( UUIDType(binary=False), db.ForeignKey("task_type.id"), index=True ) object_id = db.Column( UUIDType(binary=False), index=True ) # Sequence or Episode or Asset Type __table_args__ = ( db.UniqueConstraint( "project_id", "task_type_id", "object_id", name="schedule_item_uc", ), ) def present(self): return fields.serialize_dict( { "id": self.id, "start_date": self.start_date, "end_date": self.end_date, "man_days": self.man_days, "project_id": self.project_id, "task_type_id": self.task_type_id, "object_id": self.object_id, } )
class Playlist(db.Model, BaseMixin, SerializerMixin): """ Describes a playlist. The goal is to discuss around a defined set of shipped materials in a meeting. """ name = db.Column(db.String(80), nullable=False) shots = db.Column(JSONB) project_id = db.Column(UUIDType(binary=False), db.ForeignKey("project.id")) episode_id = db.Column(UUIDType(binary=False), db.ForeignKey("entity.id")) build_jobs = relationship("BuildJob") __table_args__ = ( db.UniqueConstraint( "name", "project_id", "episode_id", name="playlist_uc" ), )
class EntityLink(db.Model, BaseMixin, SerializerMixin): __tablename__ = "entity_link" entity_in_id = db.Column( UUIDType(binary=False), db.ForeignKey("entity.id"), primary_key=True, index=True, ) entity_out_id = db.Column( UUIDType(binary=False), db.ForeignKey("entity.id"), primary_key=True, index=True, ) nb_occurences = db.Column(db.Integer, default=1) label = db.Column(db.String(80), default="") __table_args__ = ( db.UniqueConstraint( "entity_in_id", "entity_out_id", name="entity_link_uc", ), ) @classmethod def create_from_import(cls, data): del data["type"] if "project_name" in data: del data["project_name"] entity_link = cls.get_by( entity_in_id=data["entity_in_id"], entity_out_id=data["entity_out_id"], ) if entity_link is None: return cls.create(**data), False else: entity_link.update(data) return entity_link, True
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