Beispiel #1
0
class Tour(db.Model):
    __tablename__ = "tours"

    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    artist = db.Column(db.String(255), nullable=False)
    description = db.Column(db.Text(), nullable=False)
    genre = db.Column(db.String(255), nullable=False)
    start_date = db.Column(db.DateTime(), nullable=False)
    end_date = db.Column(db.DateTime(), nullable=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey("users.id"),
                        index=True,
                        nullable=False)
    slug = db.Column(db.String(255), nullable=False, unique=True)

    def __init__(self, title, artist, description, genre, start_date, end_date,
                 user_id):
        self.title = title
        self.artist = artist
        self.description = description
        self.genre = genre
        self.start_date = start_date
        self.end_date = end_date
        self.user_id = user_id
Beispiel #2
0
class Album(db.Model):
    __tablename__ = "albums"

    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    artist = db.Column(db.String(255), nullable=False)
    description = db.Column(db.Text(), nullable=False)
    genre = db.Column(db.String(255), nullable=False)
    image = db.Column(db.Text(), nullable=False)
    release_date = db.Column(db.DateTime(), nullable=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey("users.id"),
                        index=True,
                        nullable=False)
    slug = db.Column(db.String(255), nullable=False, unique=True)

    def __init__(self, title, artist, description, genre, image, release_date,
                 user_id):
        self.title = title
        self.artist = artist
        self.description = description
        self.genre = genre
        self.image = image
        self.release_date = release_date
        self.user_id = user_id
Beispiel #3
0
class Standard(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    public_id = db.Column(GUID, default=uuid4, unique=True, nullable=False)
    type = db.Column(db.String(100), nullable=False)
    value = db.Column(db.Float, nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.now)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
Beispiel #4
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    author = db.Column(db.String(30))
    email = db.Column(db.String(254))
    site = db.Column(db.String(255))
    body = db.Column(db.Text)
    from_admin = db.Column(db.Boolean, default=False)
    reviewed = db.Column(db.Boolean, default=False)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow, index=True)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'))
    # post = db.relationship('Post', back_populates='comments')
    replied_id = db.Column(db.Integer, db.ForeignKey('comment.id'))
    replied = db.relationship('Comment',
                              back_populates='replies',
                              remote_side=[id])
    replies = db.relationship('Comment',
                              back_populates='replied',
                              cascade='all')
Beispiel #5
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(60))
    body = db.Column(db.Text)
    body_html = db.Column(db.Text)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow)
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    category = db.relationship('Category', back_populates='posts')
    comments = db.relationship('Comment', backref='post', cascade='all')
Beispiel #6
0
class LineUser(db.Model):
    __table_args__ = {"schema": "line"}
    __tablename__ = 'line_user'

    line_id = db.Column(db.String(), primary_key=True)
    lang_id = db.Column(db.Integer,
                        db.ForeignKey('line.language.id'),
                        default=1)
    image_command_id = db.Column(db.Integer,
                                 db.ForeignKey('line.image_command.id'),
                                 default=1)

    def __init__(self, line_id, lang_id):
        self.line_id = line_id
        self.lang_id = lang_id

    def __repr__(self):
        return '<line_id {}: lang_id {}>'.format(self.line_id, self.lang_id)
Beispiel #7
0
from app.extentions import db

# 导入所有数据模型,方便将来from app.modles import *
from app.models.post import Post
from app.models.user import User

# 用户-博文(M2M)中间表
collection = db.Table(
    # 表名
    'collection',

    # 定义(联合主键)

    # 定义uid列,整型,指向user表的id字段,主键之一
    db.Column('uid', db.Integer, db.ForeignKey('user.id'), primary_key=True),

    # 定义pid列,整型,指向post表的id字段,主键之一
    db.Column('pid', db.Integer, db.ForeignKey('post.id'), primary_key=True))
Beispiel #8
0
from app.extentions import db
from app.models.post import Post
from app.models.user import User

collection = db.Table(
    'collection',
    db.Column('uid',db.Integer, db.ForeignKey('user.id')),
    db.Column('pid',db.Integer, db.ForeignKey('post.id'))
)