class Artist(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), unique=True, nullable=False)
    email = db.Column(db.String(128), unique=True, nullable=False)
    podcast_id = db.Column(db.Integer, db.ForeignKey('podcast.id'))
    compose = db.relationship('Song',
                              secondary=composed,
                              backref=db.backref('composer', lazy='dynamic'))

    def __repr__(self):
        return f"Artist('{self.name}', '{self.email}', '{self.id}')"
Exemplo n.º 2
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    fname = db.Column(db.String(75), nullable=False)
    lname = db.Column(db.String(75), nullable=False)
    username = db.Column(db.String(32), unique=True, nullable=False)
    email = db.Column(db.String(128), unique=True, nullable=False)
    image_file = db.Column(db.String(32),
                           nullable=False,
                           default='default.jpeg')
    #preflang = db.Column(db.String(20), nullable=False)
    password = db.Column(db.String(60), nullable=False)
    searches = db.relationship('user_search_history',
                               backref=db.backref('user'))
    playlists = db.relationship('user_song_playlist',
                                backref=db.backref('user'))
    songs = db.relationship('Song', secondary=listened)
    posts = db.relationship('Post', backref='author', lazy=True)
    podcasts = db.relationship('Podcast', secondary=subscribed)

    def __repr__(self):
        return f"User('{self.username}', '{self.fname}', '{self.lname}', '{self.email}', '{self.image_file}')"
class Podcast(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=True)
    title = db.Column(db.String(75), nullable=False)
    description = db.Column(db.String, default='No description')
    category = db.Column(db.String, nullable=False)
    release_date = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    file_location = db.Column(db.String(20), nullable=True)
    rating = db.Column(db.Integer, default=2)
    likes = db.Column(db.Integer, default=0)
    dislikes = db.Column(db.Integer, default=0)
    artists = db.relationship('Artist', backref=db.backref('podcast'))

    def __repr__(self):
        return f"Podcast('{self.name}', '{self.category}', '{self.release_date}''{self.rating}')"
Exemplo n.º 4
0
class Artist(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), unique=True, nullable=False)
    email = db.Column(db.String(128), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpeg')
    likes = db.Column(db.Integer, default=0)
    dislikes = db.Column(db.Integer, default=0)
    rating = db.Column(db.Integer, default=2)
    podcast_id = db.Column(db.Integer, db.ForeignKey('podcast.id'))
    compose = db.relationship('Song',
                              secondary=composed,
                              backref=db.backref('composer', lazy='dynamic'))

    def __repr(self):
        return f"Artist('{self.fname}', '{self.lname}', '{self.rating}')"