class UserProjectRel(db.Model): __tablename__ = 'user_project_rel' user_id = db.Column(db.Integer, db.ForeignKey('phaunos_user.id'), primary_key=True) project_id = db.Column(db.Integer, db.ForeignKey('project.id'), primary_key=True) user_role = db.Column(ENUM(Role), nullable=False) user = db.relationship('User', backref=db.backref('user_project_rel', cascade='all')) project = db.relationship('Project', backref=db.backref('user_project_rel', cascade='all'))
class Annotation(db.Model): id = db.Column(db.Integer, primary_key=True) start_time = db.Column(db.Float, nullable=True) end_time = db.Column(db.Float, nullable=True) tag_id = db.Column(db.Integer, db.ForeignKey(Tag.id), nullable=False) project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=False) audio_id = db.Column(db.Integer, db.ForeignKey('audio.id'), nullable=False) created_by_id = db.Column(db.Integer, db.ForeignKey('phaunos_user.id')) created_by = db.relationship(User, backref=db.backref('annotations', cascade='all')) def __repr__(self): return '<id {}>'.format(self.id)
class Tag(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) created_by_id = db.Column(db.Integer, db.ForeignKey('phaunos_user.id')) created_by = db.relationship('User', backref=db.backref('tags', cascade='all')) annotations = db.relationship('Annotation', backref='tag', lazy=True, cascade='all') def __repr__(self): return '<name {}>'.format(self.name)
class Audio(db.Model): id = db.Column(db.Integer, primary_key=True) path = db.Column(db.String, unique=True, nullable=False) created_by_id = db.Column(db.Integer, db.ForeignKey('phaunos_user.id')) created_by = db.relationship(User, backref=db.backref('audios', cascade='all')) annotations = db.relationship('Annotation', backref='audio', cascade='all', lazy=True) def __repr__(self): return '<id {}>'.format(self.path)
class Tagset(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, unique=True, nullable=False) created_by_id = db.Column(db.Integer, db.ForeignKey('phaunos_user.id')) created_by = db.relationship(User, backref=db.backref('tagsets', cascade='all')) tags = db.relationship('Tag', secondary=tag_tagset_rel, lazy=True, backref='tagsets') def __repr__(self): return '<name {}>'.format(self.name)
class VisualizationType(enum.Enum): WAVEFORM = enum.auto() SPECTROGRAM = enum.auto() @enum.unique class Role(enum.Enum): PROJECTADMIN = enum.auto() PROJECTMEMBER = enum.auto() audio_project_rel = db.Table( 'audio_project_rel', db.Column('project_id', db.Integer, db.ForeignKey('project.id'), primary_key=True), db.Column('audio_id', db.Integer, db.ForeignKey('audio.id'), primary_key=True)) tagset_project_rel = db.Table( 'tagset_project_rel', db.Column('project_id', db.Integer, db.ForeignKey('project.id'), primary_key=True), db.Column('tagset_id', db.Integer, db.ForeignKey('tagset.id'),