class EntityType(db.Model): """ **EntityType** db model """ __tablename__ = 'entity_type' id = db.Column(db.String(length=60), unique=True, nullable=False, primary_key=True) name = db.Column(db.String(length=80), unique=True, nullable=False, default='') schema = db.Column(db.Text(), nullable=False) def __init__(self, **kwargs): self.id = uuid.uuid4().__str__() self.name = kwargs.get('name') self.schema = json.dumps(kwargs.get('schema')) def toDict(self): data = dict([]) data['id'] = self.id data['name'] = self.name data['schema'] = json.loads(self.schema) return data
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
class Hotel(db.Model): #set table name __tablename__ = 'hotels' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) address = db.Column(db.String(50)) zipcode = db.Column(db.Integer()) city = db.relationship('City', backref='hotels', lazy='dynamic') province = db.relationship('Province', backref='hotels', lazy='dynamic') country = db.relationship('Country', backref='hotels', lazy='dynamic') hotelfacility_id = db.relationship('HotelFacility', backref='hotels', lazy='dynamic') price = db.Column(db.Float()) def __init__(self, name, address, zipcode, province, price): self.name = name self.address = address self.zipcode = zipcode self.city = city self.province = province self.country = country self.price = price def __repr__(self): return '<Hotel>{}'.format(self.name)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) full_name = db.Column(db.Integer()) username = db.Column(db.String()) password = db.Column(db.String()) def __init__(self, full_name, username, password): self.full_name = full_name self.username = username self.password = password def is_active(self): """True, as all users are active.""" return True def get_id(self): """Return the email address to satisfy Flask-Login's requirements.""" return self.id def is_authenticated(self): """Return True if the user is authenticated.""" return True def is_anonymous(self): """False, as anonymous users aren't supported.""" return False def __repr__(self): return 'User {}'.format(self.username)
class Call(db.Model): id = db.Column(db.Integer, primary_key=True) source_phone = db.Column(db.String(11)) destination_phone = db.Column(db.String(11)) started_date = db.Column(db.DateTime, nullable=True) finished_date = db.Column(db.DateTime, nullable=True) call_identifier = db.Column(db.Integer, unique=True) price = db.Column(db.Float, nullable=True)
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) full_name = db.Column(db.String(25)) email = db.Column(db.String(30)) birthday = db.Column(db.DateTime) created = db.Column(db.DateTime, default=datetime.utcnow(), nullable=False) def __init__(self, full_name, email, birthday): self.full_name = full_name self.email = email self.birthday = birthday def __repr__(self): return '<User {}>'.format(self.full_name)
class Roles(db.Model): __tablename__ = 'roles' id = db.Column(db.Integer, primary_key=True) role = db.Column(db.String(15)) description = db.Column(db.String(50)) def __init__(self, role, description): self.role = role self.description = description def __repr__(self): return '<Roles{}>'.format(self.role)
class Question(db.Model): __tablename__ = 'question' id = db.Column(db.Integer, primary_key=True) teks = db.Column(db.String(120)) def __init__(self, teks): self.teks = teks
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)
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)
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)
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(50)) fullname = db.Column(db.String(50)) email = db.Column(db.String(20)) address = db.Column(db.String(50)) phone_number = db.Column(db.String(12)) password = db.Column(db.String(30)) profile = db.relationship('Profile', backref='user', lazy = 'dynamic') created_time = db.Column(db.DateTime, default = datetime.now) lastlogin_time = db.Column(db.DateTime) def __init__(self, username, fullname, email, address, phone_number, password): self.username = username self.fullname = fullname self.email = email self.address = address self.phone_number = phone_number self.password = password def __repr__(self): return '<User{}>'.format(self.username)