コード例 #1
0
class User(db.Model):
    __tablename__ = "users"
    id = db.Column('user_id', db.Integer, primary_key=True)
    username = db.Column('username', db.String(20), unique=True, index=True)
    password = db.Column('password', db.String(10))
    email = db.Column('email', db.String(50), unique=True, index=True)
    registered_on = db.Column('registered_on', db.DateTime)
    day = db.Column('day', db.Integer)
    post = db.relationship('Post', backref='user', lazy='dynamic')

    def __init__(self, username, password, email):
        self.username = username
        self.password = password
        self.email = email
        self.registered_on = datetime.utcnow()
        self.day = 1

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.id

    def __repr__(self):
        return '[User {}: Day: {}]'.format(self.username, self.day)
コード例 #2
0
class DbInfo(db.Model):
    __tablename__ = "dbinfo"
    id = db.Column(db.Integer, primary_key=True)
    last_updated = db.Column(db.Integer)
    root_name = db.Column(db.String(50))
    root_pass = db.Column(db.String(50))

    def __repr__(self):
        return '[Database: last_updated: {} root: {}'.format(
            self.last_updated, self.root_name)

    def __init__(self, time_here, root_u, root_p):
        self.last_updated = time_here
        self.root_name = root_u
        self.root_pass = root_p
コード例 #3
0
ファイル: models.py プロジェクト: clearnote01/writeeveryday
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    uname = db.Column(db.String(30))
    upass = db.Column(db.String(30))
    email = db.Column(db.String(30))
    name = db.Column(db.String(30))
    roll_no = db.Column(db.String(20))
    branch = db.Column(db.String(30))
    # date_of_join = db.Column(db.DateTime())
    usertags = db.relationship('UserTag', backref='user', lazy="dynamic")
    questions = db.relationship('Question', backref='user', lazy="dynamic")
    answers = db.relationship('Answer', backref='user', lazy="dynamic")
    user_date = db.Column(db.DateTime)

    def __init__(self, uname, upass, email, name, roll_no, branch):
        self.uname = uname
        self.upass = upass
        self.email = email
        self.name = name
        self.roll_no = roll_no
        self.branch = branch
        user_date = date.today()
        self.user_date = user_date

    def __repr__(self):
        return ('<User {}>'.format(self.uname))
コード例 #4
0
ファイル: models.py プロジェクト: clearnote01/writeeveryday
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))
コード例 #5
0
ファイル: models.py プロジェクト: clearnote01/writeeveryday
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))
コード例 #6
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)
コード例 #7
0
ファイル: models.py プロジェクト: clearnote01/writeeveryday
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))
コード例 #8
0
ファイル: models.py プロジェクト: clearnote01/writeeveryday
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))