Пример #1
0
class Relationship(db.Model):
    __table_args__ = {'extend_existing': True}
    __tablename__ = 'relationship'
    relation_id = db.Column(db.Integer, primary_key=True)
    userID_1 = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    userID_2 = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    dtr = db.Column(db.String(50), nullable=True)

    def __repr__(self):
        return '<Relationship {}>'.format(self.relation_id)
Пример #2
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_comment = db.Column(db.String(200), nullable=False)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    #parent_id = db.Column(db.Integer, db.ForeignKey('comment.id'))
    #replies = db.relationship('Comment', backref=db.backref('parent', remote_side=[id]),lazy='dynamic')
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    article_id = db.Column(db.Integer,
                           db.ForeignKey("article.id"),
                           nullable=False)
Пример #3
0
class Article(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False, unique=True)
    article_content = db.Column(db.Text)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    abstract = db.Column(db.String(150), nullable=False)
    category_id = db.Column(db.Integer,
                            db.ForeignKey("category.id"),
                            nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    comments = db.relationship("Comment", backref="article", lazy=True)
Пример #4
0
class Comment(db.Model):
    __table_args__ = {'extend_existing': True}
    __tablename__ = 'comment'
    commentID = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.Text, nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)

    def __repr__(self):
        return '<Comment {}>'.format(self.commentID)
Пример #5
0
class Post(db.Model):
    __table_args__ = {'extend_existing': True}
    __tablename__ = 'post'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = db.Column(db.Text)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    author = db.Column(db.String(20), unique=True, nullable=False)

    def __repr__(self):
        return '<Post {}>'.format(self.id)