Esempio n. 1
0
class Answer(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    answer_text = db.Column(db.String(1000))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    ans_date = db.Column(db.DateTime)

    def __init__(self, answer_text, user, question):
        self.answer_text = answer_text
        self.user = user
        self.question = question
        ans_date = date.today()
        self.ans_date = ans_date

    def __repr__(self):
        return ('<answer {}>'.format(self.answer_text))
Esempio n. 2
0
class UserTag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(220))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    ut_date = db.Column(db.DateTime)

    def __init__(self, name, user):
        self.name = name
        self.user = user
        ut_date = date.today()
        self.ut_date = ut_date

    def __repr__(self):
        return ('<UserTag {}>'.format(self.name))
Esempio n. 3
0
class QuestionTag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(1000))
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    qt_date = db.Column(db.DateTime)

    def __init__(self, name, question):
        self.name = name
        self.question = question
        qt_date = date.today()
        self.qt_date = qt_date

    def __repr__(self):
        return ('<questiontag {}>'.format(self.name))
Esempio n. 4
0
class Post(db.Model):
    __tablename__ = "posts"
    id = db.Column('post_id', db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.user_id'))
    completed = db.Column('completed', db.Integer)
    text = db.Column('post_text', db.String(10000))
    day = db.Column('post_day', db.Integer)

    def __init__(self, user, text, day, words=0, completed=0):
        self.user = user
        self.text = text
        self.day = day
        self.completed = completed

    def __repr__(self):
        return '[ Post: Day: {} : {} ]'.format(self.day, self.text)
Esempio n. 5
0
class Question(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    question_text = db.Column(db.String(1000))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    question_tags = db.relationship('QuestionTag',
                                    backref='question',
                                    lazy='dynamic')  #relatioship with question
    answers = db.relationship('Answer', backref='question', lazy='dynamic')
    qu_date = db.Column(db.DateTime)

    def __init__(self, question_text, user):
        self.question_text = question_text
        self.user = user
        qu_date = date.today()
        self.qu_date = qu_date

    def __repr__(self):
        return ('<Question :{}>'.format(self.question_text))