示例#1
0
class IdeaComment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    idea_id = db.Column(db.Integer, db.ForeignKey('idea.id'))
示例#2
0
class Idea(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    link = db.Column(db.String(200), nullable=True)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    description = db.Column(db.Text, nullable=False)
    thumbnail = db.Column(db.String(20), nullable=True)
    main_image = db.Column(db.String(20), nullable=True)
    view_count = db.Column(db.Integer, nullable=True, default=0)
    topic = db.Column(db.String(200), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    yesses = db.relationship('IdeaYes',
                             backref='idea',
                             lazy='dynamic',
                             cascade='all,delete')
    noes = db.relationship('IdeaNo',
                           backref='idea',
                           lazy='dynamic',
                           cascade='all,delete')
    upvotes = db.relationship('Upvote',
                              backref='idea',
                              lazy='dynamic',
                              cascade='all,delete')
    comments = db.relationship('IdeaComment',
                               backref='idea',
                               lazy='dynamic',
                               cascade='all,delete')
示例#3
0
class IdeaNo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    idea_id = db.Column(db.Integer, db.ForeignKey('idea.id'))