示例#1
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))
示例#2
0
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))
示例#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))
示例#4
0
class User(db.Model):
    """ Model class for Users settings """

    __tablename__ = "t_users"

    user_id = db.Column(db.Integer, primary_key=True)
    locale = db.Column(db.String, nullable=False)

    def __init__(self, user_id, locale):
        self.user_id = user_id
        self.locale = locale

    def __repr__(self):
        return u"User user_id:{}, locale:{}".format(self.user_id, self.locale)
示例#5
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
示例#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
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
class BibleVerse(db.Model):
    """ Model class for Bible quote """

    __tablename__ = "t_bible_verse"

    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.String, nullable=False)
    address = db.Column(db.String)

    def __init__(self, text, address):
        self.text = text
        self.address = address

    def __repr__(self):
        return u"BibleVerse id:{}, text:{}, address:{}".format(
            self.id, self.text, self.address)
示例#9
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))
示例#10
0
class Intent(db.Model):
    """ Intent """

    __tablename__ = 't_intent'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String)
    description = db.Column(db.String)
    ts = db.Column(db.Integer)
    commiter_id = db.Column(db.Integer)

    def __init__(self, user_id, description):
        self.user_id = user_id
        self.description = description
        self.commiter_id = ''

    def __repr__(self):
        return u"<Intent id:{}, user_id: {}, desc:{}>".format(
            self.id, self.user_id, self.description)
示例#11
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)
示例#12
0
class Intent(db.Model):
    """ Model class for Intentions """

    __tablename__ = 't_intent'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String)
    description = db.Column(db.String)
    ts = db.Column(db.Integer)
    commiter_id = db.Column(db.Integer, nullable=False)
    confirmed = db.Column(db.Integer, nullable=False)

    def __init__(self, user_id, description):
        self.user_id = user_id
        self.description = description
        self.commiter_id = 0
        self.confirmed = 0

    def __repr__(self):
        return u"<Intent id:{}, user_id: {}, desc:{}>".format(
            self.id, self.user_id, self.description).encode('utf-8')