Exemple #1
0
class Post(db.Model):
    __tablename__ = 'post'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.VARCHAR(50))
    slug = db.Column(db.VARCHAR(50))
    content = db.Column(db.VARCHAR(100))
    id_user = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('Post', lazy='dynamic'))
    id_post_type = db.Column(db.Integer, db.ForeignKey('post_type.id'))
    post_type = db.relationship('Post_type',
        backref=db.backref('Post', lazy='dynamic'))
    createdtime = db.Column(db.DateTime)
    updatetime = db.Column(db.DateTime)
    deletedtime = db.Column(db.DateTime)
    deleted = db.Column(db.Boolean)

    def __init__(self, title, content, id_post_type, id_user):
        self.title = title
        self.content = content
        self.id_post_type = id_post_type
        self.id_user = id_user
        self.slug = slugify(unicode(self.title))
        self.createdtime = datetime.datetime.now()
        self.updatetime = datetime.datetime.now()
        self.deleted = 0

    def __repr__(self):
        return "<Post: %s>"%self.title
Exemple #2
0
class Social_Media_User(db.Model):
    __tablename__ = 'social_media_user'
    id = db.Column(db.Integer, primary_key=True)
    id_socmed = db.Column(db.Integer, db.ForeignKey('social_media.id'))
    social_media = db.relationship('Social_Media',
        backref=db.backref('socmed_user', lazy='dynamic'))
    id_user = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('socmed_user', lazy='dynamic'))
    value = db.Column(db.VARCHAR(45))
    createdtime = db.Column(db.DateTime)
    updatedtime = db.Column(db.DateTime)
    deletedtime = db.Column(db.DateTime)
    deleted = db.Column(db.Boolean)
Exemple #3
0
class UserRoles(db.Model):

    __tablename__ = 'user_roles'
    id = db.Column(db.Integer, primary_key=True)
    roleid = db.Column(db.Integer, db.ForeignKey(Roles.id))
    userid = db.Column(db.Integer, db.ForeignKey(User.id))

    def __init__(self, roleid, userid):

        self.roleid = roleid
        self.userid = userid

    def __repr__(self):

        return '<UserRoles{}>'.format(self.roleid)
Exemple #4
0
class Entity(db.Model):
    """ **EntityType** db model """

    __tablename__ = 'entity'

    id = db.Column(
        db.String(length=60),
        unique=True,
        nullable=False,
        primary_key=True,
    )

    entityTypeId = db.Column(db.String(length=60),
                             db.ForeignKey('entity_type.id'),
                             nullable=False)

    content = db.Column(db.Text(), nullable=False)

    def __init__(self, **kwargs):
        self.id = uuid.uuid4().__str__()
        self.entityTypeId = kwargs.get('entity_type_id')
        self.content = json.dumps(kwargs.get('content'))

    def toDict(self):
        data = dict([])
        data['id'] = self.id
        data['entity_type_id'] = self.entityTypeId
        data['content'] = json.loads(self.content)
        return data
Exemple #5
0
class Post_type(db.Model):
    __tablename__ = 'post_type'
    id = db.Column(db.Integer, primary_key=True)
    post_type = db.Column(db.VARCHAR(10))
    created_by = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('Post_type', lazy='dynamic'))
    description = db.Column(db.VARCHAR(45))
Exemple #6
0
class User_answer(db.Model):
    __tablename__ = 'user_answer'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('answers', lazy='dynamic'))
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    question = db.relationship('Question',
        backref=db.backref('answers', lazy='dynamic'))
    answer = db.Column(db.Boolean)

    def __init__(self, user_id, question_id, answer):
        self.user_id = user_id
        self.question_id = question_id
        self.answer = answer

    def __repr__(self):
        return '<UserAnswer %d>'%(self.answer)
Exemple #7
0
class Comment(db.Model):
    __tablename__ = 'comment'
    id = db.Column(db.Integer, primary_key=True)
    id_post = db.Column(db.Integer, db.ForeignKey('post.id'))
    post = db.relationship('Post',
        backref=db.backref('Comment', lazy='dynamic'))
    id_user = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('Comment', lazy='dynamic'))
    desc = db.Column(db.VARCHAR(50))
    createdtime = db.Column(db.DateTime)
    updatetime = db.Column(db.DateTime)
    deletedtime = db.Column(db.DateTime)
    deleted = db.Column(db.Boolean)

    def __init__(self, id_post, id_user, desc):
        self.id_post = id_post
        self.id_user = id_user
        self.desc = desc
        self.createdtime = datetime.datetime.now()
        self.updatetime = datetime.datetime.now()
        self.deleted = 0
Exemple #8
0
class Vote(db.Model):
    __tablename__ = 'vote'
    id = db.Column(db.Integer, primary_key=True)
    id_post = db.Column(db.Integer, db.ForeignKey('post.id'))
    post = db.relationship('Post',
        backref=db.backref('Vote', lazy='dynamic'))
    id_user = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('Vote', lazy='dynamic'))
    createdtime = db.Column(db.DateTime)
    updatetime = db.Column(db.DateTime)
    deletedtime = db.Column(db.DateTime)
    deleted = db.Column(db.Boolean)

    def __init__(self, id_post, id_user):
        self.id_post = id_post
        self.id_user = id_user
        self.createdtime = datetime.datetime.now()
        self.updatetime = datetime.datetime.now()
        self.deleted = 0

    def __repr__(self):
        return "<Vote %s>"%self.post.title
Exemple #9
0
class Country(db.Model):
    #set table name
    __tablename__ = 'country'
    id = db.Column(db.Integer, primary_key=True)
    hotel_id = db.Column(db.Integer, db.ForeignKey(Hotel.id))
    country = db.Column(db.String(50))
    code = db.Column(db.String(50))

    def __init__(self, hotel_id, country, code):

        self.hotel_id = hotel_id
        self.country = country
        self.code = code

    def __repr__(self):

        return '<Country>{}'.format(self.country)
Exemple #10
0
class Province(db.Model):
    #set table name
    __tablename__ = 'province'
    id = db.Column(db.Integer, primary_key=True)
    hotel_id = db.Column(db.Integer, db.ForeignKey(Hotel.id))
    province = db.Column(db.String(50))
    code = db.Column(db.String(50))

    def __init__(self, hotel_id, province, code):

        self.hotel_id = hotel_id
        self.province = province
        self.code = code

    def __repr__(self):

        return '<Province>{}'.format(self.province)
Exemple #11
0
class Profile(db.Model):

    __tablename__ = 'profile'
    id = db.Column(db.Integer, primary_key=True)
    userid = db.Column(db.Integer, db.ForeignKey(User.id))
    birthdate = db.Column(db.DateTime)
    birthplace = db.Column(db.String(50))
    gander = db.Column(db.String(50))

    def __init__(self, userid, birthdate, birthplace, gander):

        self.userid = userid
        self.birthdate = birthdate
        self.birthplace = birthplace
        self.gander = gander

    def __repr__(self):

        return '<Profile{}>'.format(self.userid)
Exemple #12
0
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    full_name = db.Column(db.VARCHAR(45))
    username = db.Column(db.VARCHAR(15), unique=True)
    password = db.Column(db.VARCHAR(128))
    email = db.Column(db.VARCHAR(30), unique=True)
    bio = db.Column(db.VARCHAR(20))
    picture = db.Column(db.VARCHAR(50))
    updatedtime = db.Column(db.DateTime)
    createdtime = db.Column(db.DateTime)
    deletedtime = db.Column(db.DateTime)
    deleted = db.Column(db.Boolean)
    last_login = db.Column(db.DateTime)
    id_type_user = db.Column(db.Integer, db.ForeignKey('user_type.id'))
    type_user = db.relationship('User_Type',
        backref=db.backref('user', lazy='dynamic'))

    def __init__(self, full_name, username, email, password):
        self.full_name = full_name
        self.username = username
        self.email = email
        self.password = generate_password_hash(password)
        self.createdtime = datetime.datetime.now()
        self.updatedtime = datetime.datetime.now()
        self.deleted = 0
        self.id_type_user = 5

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def get_id(self):
        return unicode(self.id)

    def is_anonymous(self):
        return False

    def __repr__(self):
        return "<Username: %s>"%self.username
Exemple #13
0
class HotelFacility(db.Mdel):
    #set table name
    __tablename__ = 'hotelfacility'
    id = db.column(db.Integer, primary_key=True)
    hotelid = db.Column(db.Integer, db.ForeignKey(Hotel.id))
    garage = db.Column(db.Integer)
    carports = db.Column(db.Integer)
    swimmpingpool = db.Column(db.Integer)

    def __init__(self, hotelid, garage,
                 carports, swimmingpool):

        self.hotelid = hotelid
        self.garage = garage
        self.carports = carports
        self.swimmingpool = swimmingpool

    def __repr__(self):

        return '<HotelFacility>{}'.format(self.garage)