Exemplo n.º 1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), nullable=False)
    password = db.Column(db.String(60), nullable=False)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow)

    following = db.relationship("Follow", back_populates="user")
Exemplo n.º 2
0
class Channel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    channel_name = db.Column(db.String(40), nullable=False)
    admin_id = db.Column(db.Integer, nullable=True, default=None)
    public = db.Column(db.Boolean(), nullable=False, default=True)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow)

    posts = db.relationship("Post", back_populates="channel")
    followers = db.relationship("Follow", back_populates="channel")
Exemplo n.º 3
0
class Follow(db.Model):
    """Association Table between the users and channels"""
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
    chan_id = db.Column(db.Integer,
                        db.ForeignKey('channel.id'),
                        primary_key=True)

    channel = db.relationship("Channel", back_populates="followers")
    user = db.relationship("User", back_populates="following")
Exemplo n.º 4
0
class Post(db.Model):
    """Association Table between User and Channel"""
    id = db.Column(db.Integer, primary_key=True)
    chan_id = db.Column(db.Integer, db.ForeignKey('channel.id'))
    user_name = db.Column(db.String(20), nullable=False)
    text = db.Column(db.Text, nullable=False)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow)

    channel = db.relationship("Channel", back_populates="posts")
Exemplo n.º 5
0
class User(db.Model, UserMixin, Base):
    id = db.Column(db.Integer, primary_key=True)
    user_name = db.Column(db.String(20), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    profile_image = db.Column(
        db.String(20),
        nullable=False,
        default='user_profile.png')
    password = db.Column(db.String(60), nullable=True)
    courses = db.relationship('Course', backref='author', lazy=True)
    categories = db.relationship('Category', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.user_name}', '{self.email}', '{self.image_file}')"
Exemplo n.º 6
0
class Course(db.Model, Base):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.Text, nullable=False)
    price = db.Column(db.Integer)
    Category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
Exemplo n.º 7
0
class Category(db.Model, Base):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    courses = db.relationship('Course', backref='category', lazy=True)
Exemplo n.º 8
0
class OAuth (db.Model, OAuthConsumerMixin, Base):
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    courses = db.relationship(User)