示例#1
0
文件: models.py 项目: mmisz/pracaL
class Track(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(128), nullable=False)
    date_release = db.Column(db.SmallInteger, nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    date_last_update = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    lyrics = db.Column(db.Text, nullable=False)
    lyrics_with_scraps = db.Column(db.Text, nullable=False)
    lyrics_by = db.Column(db.String(128), nullable=True)
    published = db.Column(db.SmallInteger, default=0, nullable=False)
    description = db.Column(db.Text, nullable=True)
    albums = db.relationship(
        "Album",
        secondary=TrackAlbums,
        back_populates="tracks",
        passive_deletes=True
    )
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    scraps = db.relationship('Scrap', backref='track', lazy=True)
    translations = db.relationship('Translation', backref='track', lazy=True)
    comments = db.relationship('Track_Post', backref='track', lazy=True)
    interpretations = db.relationship('Interpretation', backref='track', lazy=True)

    def __repr__(self):
        return f"Track('{self.title}', '{self.date_release}')"
示例#2
0
文件: models.py 项目: mmisz/pracaL
class Interpretation_Rating(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    rate = db.Column(db.String(1), nullable=False)
    interpretation_id = db.Column(db.Integer, db.ForeignKey('interpretation.id'), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Scrap_Rating('{self.scrap_id}', '{self.rate}')"
示例#3
0
文件: models.py 项目: mmisz/pracaL
class Thread(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    topic = db.Column(db.String(128), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    date_last_update = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    description = db.Column(db.Text, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    threads = db.relationship('Thread_Post', backref='thread', lazy=True)

    def __repr__(self):
        return f"Thread('{self.date_posted}', '{self.topic}')"
示例#4
0
文件: models.py 项目: mmisz/pracaL
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    is_admin = db.Column(db.Boolean, nullable=False)
    threads = db.relationship('Thread', backref='author', lazy=True)
    tracks = db.relationship('Track', backref='author', lazy=True)
    thread_posts = db.relationship('Thread_Post', backref='author', lazy=True)
    track_post = db.relationship('Track_Post', backref='author', lazy=True)
    scrap = db.relationship('Scrap', backref='author', lazy=True)
    scrap_Opinion = db.relationship('Scrap_Opinion', backref='author', lazy=True)
    translation = db.relationship('Translation', backref='author', lazy=True)
    translation_Opinion = db.relationship('Translation_Opinion', backref='author', lazy=True)
    #discussion_Post = db.relationship('Discussion_Post', backref='author', lazy=True)
    interpretation = db.relationship('Interpretation', backref='author', lazy=True)
    interpretation_Post = db.relationship('Interpretation_Opinion', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
示例#5
0
文件: models.py 项目: mmisz/pracaL
class Interpretation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(128), nullable=False)
    text = db.Column(db.Text, nullable=True)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    date_last_update = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    track_id = db.Column(db.Integer, db.ForeignKey('track.id'), nullable=False)
    opinions = db.relationship('Interpretation_Opinion', backref='translation', lazy=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Interpretation"
示例#6
0
文件: models.py 项目: mmisz/pracaL
class Album(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(128), nullable=False)
    date_release = db.Column(db.SmallInteger, nullable=False)
    description = db.Column(db.Text, nullable=True)
    tracks = db.relationship(
        "Track",
        secondary=TrackAlbums,
        back_populates="albums",
        cascade="all, delete",
    )

    def __repr__(self):
        return f"Album('{self.title}', '{self.date_release}')"