Ejemplo n.º 1
0
class Aid(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(50), nullable=False)
    artist = db.Column(db.String(30), nullable=False)
    album = db.Column(db.String(30), nullable=True)
    story = db.Column(db.String(250), nullable=True)
    hits = db.relationship('Hit', backref='aid', lazy=True)
    genre = db.Column(db.String(20), nullable=True)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    userid = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Aid('{self.title}', '{self.artist}')"
Ejemplo n.º 2
0
class User(UserMixin ,db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(100), unique=True, nullable=False)
    password = db.Column(db.String(50), nullable=False)
    date_joined = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    image_file = db.Column(db.String(20), default='default.jpg', nullable=False)
    aids = db.relationship('Aid', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
    
    def set_password(self, password):
        self.password = generate_password_hash(password)
    
    def check_password(self, password):
        return check_password_hash(self.password, password)
Ejemplo n.º 3
0
class Hit(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    userid = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    aidid = db.Column(db.Integer, db.ForeignKey('aid.id'), nullable=False)
    timestamp = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
Ejemplo n.º 4
0
class Chat(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    userid = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=True)
    username = db.Column(db.String(20), nullable=False)
    message = db.Column(db.String(150), nullable=False)
    time = db.Column(db.Time, nullable=False, default=datetime.utcnow().time)
Ejemplo n.º 5
0
class Spotify(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    userid = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    code = db.Column(db.String(100), nullable=False)
    date_linked = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)