Exemple #1
0
class UsersRoles(db.Model):
    """ User model """
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer(), primary_key=True)
    user_id = db.Column(db.Integer(), db.ForeignKey(
        'user.id', ondelete='CASCADE'))
    role_id = db.Column(db.Integer(), db.ForeignKey(
        'role.id', ondelete='CASCADE'))
Exemple #2
0
class Room(db.Model):
    """ Create a Room table """
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer(), primary_key=True)
    type = db.Column(db.String(), nullable=False)
    quantity = db.Column(db.Integer(), nullable=False, default=0)
    tenant_id = db.Column(
        db.Integer(), db.ForeignKey('user.id'), nullable=True)
    booking_id = db.Column(
        db.Integer(), db.ForeignKey('booking.id'), nullable=True)

    def __repr__(self):
        return '<Room %r>' % (self.roomtype)
Exemple #3
0
class Post(db.Model):
    """ Create a blog table """
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(), nullable=False)
    summary = db.Column(db.String(), nullable=False)
    content = db.Column(db.String(), nullable=False)
    image_path = db.Column(db.String(), nullable=True)
    image_feature1 = db.Column(db.String(), nullable=True)
    image_feature2 = db.Column(db.String(), nullable=True)
    image_feature3 = db.Column(db.String(), nullable=True)
    view_count = db.Column(db.Integer(), nullable=False, default=0)
    comment_count = db.Column(db.Integer(), nullable=False, default=0)
    published = db.Column(db.Boolean(), nullable=False, default=False)
    publish_date = db.Column(db.DateTime())
    created = db.Column(db.DateTime(), nullable=False)
    updated = db.Column(db.DateTime(), default=datetime.utcnow())
    comments = db.relationship(
        'Comment', backref='post', lazy=True, cascade="all, delete-orphan")
    tags = db.relationship('Tag',
                           secondary='posts_tags',
                           lazy='subquery',
                           backref=db.backref('post', lazy=True))
    author_id = db.Column(
        db.Integer(), db.ForeignKey('user.id'), nullable=False)
    author = db.relationship('User')

    def __repr__(self):
        return '<Post %r>' % (self.title)
Exemple #4
0
class Comment(db.Model):
    """ Create a Comment table """
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(), nullable=False)
    email = db.Column(db.String(), nullable=False)
    content = db.Column(db.String(), nullable=False)
    date = db.Column(db.DateTime(), default=datetime.utcnow())
    post_id = db.Column(
        db.Integer(), db.ForeignKey('post.id'), nullable=False)

    def __repr__(self):
        return '<Comment %r>' % (self.name)
Exemple #5
0
class PostsTags(db.Model):
    """ create a posts tags table """
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer(), primary_key=True)
    post_id = db.Column(db.Integer(), db.ForeignKey('post.id'))
    tag_id = db.Column(db.Integer(), db.ForeignKey('tag.id'))