class SupermarketModel(BaseModel): __tablename__ = 'supermarkets' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(100), nullable=False, unique=True) address = db.Column(db.String(100), nullable=False) _open_time = db.Column("open_time", db.Integer(), nullable=False) _close_time = db.Column("close_time", db.Integer(), nullable=False) @property def open_time(self): """Return open_time value""" return seconds_to_time(self._open_time) @open_time.setter def open_time(self, value): """Set open_time value """ self._open_time = time_to_seconds(value) @property def close_time(self): """Return close_time value""" return seconds_to_time(self._close_time) @close_time.setter def close_time(self, value): """Set close_time value""" self._close_time = time_to_seconds(value)
class VehicleResource(db.Model): __tablename__ = 'scheduler_vehicle_resources' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) license = db.Column('license', db.String(8), nullable=False) maker = db.Column('maker', db.String(16), nullable=False) model = db.Column('model', db.String(16)) year = db.Column('year', db.String(4)) occupancy = db.Column('occupancy', db.Integer(), nullable=False) desc = db.Column('desc', db.Text()) business_hour_start = db.Column('business_hour_start', db.Time()) business_hour_end = db.Column('business_hour_end', db.Time()) availability_id = db.Column('availability_id', db.ForeignKey('scheduler_vehicle_avails.id')) type_id = db.Column('type_id', db.ForeignKey('scheduler_vehicle_types.id'))
class EventCategory(db.Model): __tablename__ = 'scheduler_event_categories' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) category = db.Column('category', db.String(255)) def __str__(self): return u'{}'.format(self.category)
class SmartClassResourceType(db.Model): __tablename__ = 'smartclass_scheduler_resource_types' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) resource_type = db.Column('type', db.String(length=32)) def __repr__(self): return self.resource_type
class VehicleType(db.Model): __tablename__ = 'scheduler_vehicle_types' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) type = db.Column('type', db.String(length=32)) vehicles = db.relationship('VehicleResource', backref='type') def __repr__(self): return self.type
class VehicleAvailability(db.Model): __tablename__ = 'scheduler_vehicle_avails' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) availability = db.Column('availability', db.String(length=32)) vehicles = db.relationship('VehicleResource', backref='availability') def __repr__(self): return self.availability
class RoomResource(db.Model): __tablename__ = 'scheduler_room_resources' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) location = db.Column('location', db.String(length=16)) number = db.Column('number', db.String(16)) occupancy = db.Column('occupancy', db.Integer(), nullable=False) desc = db.Column('desc', db.Text()) business_hour_start = db.Column('business_hour_start', db.Time()) business_hour_end = db.Column('business_hour_end', db.Time()) availability_id = db.Column('availability_id', db.ForeignKey('scheduler_room_avails.id')) type_id = db.Column('type_id', db.ForeignKey('scheduler_room_types.id')) reservations = db.relationship('RoomEvent', backref='room') equipments = db.relationship(AssetItem, backref=db.backref('room')) def __repr__(self): return u'Room: {}, ID: {}'.format(self.number, self.id)
class SmartClassOnlineAccountEvent(db.Model): __tablename__ = 'smartclass_scheduler_online_account_events' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) account_id = db.Column( 'account_id', db.ForeignKey('smartclass_scheduler_online_accounts.id'), nullable=False) title = db.Column('title', db.String(255), nullable=False, info={'label': u'กิจกรรม'}) start = db.Column('start', db.DateTime(timezone=True), nullable=False, info={'label': u'เริ่ม'}) end = db.Column('end', db.DateTime(timezone=True), nullable=False, info={'label': u'สิ้นสุด'}) occupancy = db.Column('occupancy', db.Integer(), info={'label': u'ผู้เข้าร่วม'}) approved = db.Column('approved', db.Boolean(), default=True) created_at = db.Column('created_at', db.DateTime(timezone=True), server_default=func.now()) created_by = db.Column('created_by', db.ForeignKey('staff_account.id')) creator = db.Column('creator', db.String(), nullable=True, info={'label': u'ชื่อผู้ลงทะเบียน'}) updated_at = db.Column('updated_at', db.DateTime(timezone=True), server_default=None) updated_by = db.Column('updated_by', db.ForeignKey('staff_account.id')) cancelled_at = db.Column('cancelled_at', db.DateTime(timezone=True), server_default=None) cancelled_by = db.Column('cancelled_by', db.ForeignKey('staff_account.id')) approved_by = db.Column('approved_by', db.ForeignKey('staff_account.id')) approved_at = db.Column('approved_at', db.DateTime(timezone=True), server_default=None) note = db.Column('note', db.Text(), info={'label': u'หมายเหตุ'}) account = db.relationship(SmartClassOnlineAccount, backref=db.backref('events'))
class VehicleBooking(db.Model): __tablename__ = 'scheduler_vehicle_bookings' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) vehicle_id = db.Column('vehicle_id', db.ForeignKey('scheduler_vehicle_resources.id'), nullable=False) vehicle = db.relationship('VehicleResource', backref=db.backref('bookings')) title = db.Column('title', db.String(255), nullable=False) init_milage = db.Column('init_milage', db.Integer, nullable=True) end_milage = db.Column('end_milage', db.Integer, nullable=True) toll_fee = db.Column('toll_fee', db.Float(), default=0.0) distance = db.Column('distance', db.Integer, nullable=True) init_location = db.Column('init_location', db.String(255), nullable=True) destination = db.Column('destination', db.String(255), nullable=True) start = db.Column('start', db.DateTime(timezone=True), nullable=False) end = db.Column('end', db.DateTime(timezone=True), nullable=False) iocode_id = db.Column('iocode_id', db.ForeignKey('iocodes.id')) iocode = db.relationship('IOCode', backref=db.backref('vehicle_bookings')) org_id = db.Column('org_id', db.ForeignKey('orgs.id')) org = db.relationship('Org', backref=db.backref('vehicle_bookings')) num_passengers = db.Column('num_passengers', db.Integer()) approved = db.Column('approved', db.Boolean(), default=False) closed = db.Column('closed', db.Boolean(), default=False) created_at = db.Column('created_at', db.DateTime(timezone=True), server_default=func.now()) created_by = db.Column('created_by', db.ForeignKey('staff_account.id')) updated_at = db.Column('updated_at', db.DateTime(timezone=True), server_default=None) updated_by = db.Column('updated_by', db.ForeignKey('staff_account.id')) cancelled_at = db.Column('cancelled_at', db.DateTime(timezone=True), server_default=None) cancelled_by = db.Column('cancelled_by', db.ForeignKey('staff_account.id')) approved_by = db.Column('approved_by', db.ForeignKey('staff_account.id')) approved_at = db.Column('approved_at', db.DateTime(timezone=True), server_default=None) desc = db.Column('desc', db.Text()) google_event_id = db.Column('google_event_id', db.String(64)) google_calendar_id = db.Column('google_calendar_id', db.String(255))
class RoomEvent(db.Model): __tablename__ = 'scheduler_room_reservations' id = db.Column('id', db.Integer(), primary_key=True, autoincrement=True) room_id = db.Column('room_id', db.ForeignKey('scheduler_room_resources.id'), nullable=False) category_id = db.Column('category_id', db.ForeignKey('scheduler_event_categories.id')) category = db.relationship('EventCategory', backref=db.backref('events')) title = db.Column('title', db.String(255), nullable=False) start = db.Column('start', db.DateTime(timezone=True), nullable=False) end = db.Column('end', db.DateTime(timezone=True), nullable=False) iocode_id = db.Column('iocode_id', db.ForeignKey('iocodes.id')) occupancy = db.Column('occupancy', db.Integer()) # number of sets of food/refreshment requested refreshment = db.Column('refreshment', db.Integer(), default=0) request = db.Column('request', db.Text()) # comma separated list of things approved = db.Column('approved', db.Boolean(), default=True) created_at = db.Column('created_at', db.DateTime(timezone=True), server_default=func.now()) created_by = db.Column('created_by', db.ForeignKey('staff_account.id')) updated_at = db.Column('updated_at', db.DateTime(timezone=True), server_default=None) updated_by = db.Column('updated_by', db.ForeignKey('staff_account.id')) cancelled_at = db.Column('cancelled_at', db.DateTime(timezone=True), server_default=None) cancelled_by = db.Column('cancelled_by', db.ForeignKey('staff_account.id')) approved_by = db.Column('approved_by', db.ForeignKey('staff_account.id')) approved_at = db.Column('approved_at', db.DateTime(timezone=True), server_default=None) extra_items = db.Column('extra_items', db.JSON) note = db.Column('note', db.Text()) google_event_id = db.Column('google_event_id', db.String(64)) google_calendar_id = db.Column('google_calendar_id', db.String(255))
class DocDocument(db.Model): __tablename__ = 'doc_documents' id = db.Column(db.Integer, primary_key=True, autoincrement=True) round_id = db.Column(db.ForeignKey('doc_rounds.id')) round = db.relationship(DocRound, backref=db.backref('documents', lazy='dynamic', order_by='DocDocument.number', cascade='all, delete-orphan')) number = db.Column(db.Integer(), info={'label': u'Number'}) deadline = db.Column(db.DateTime(timezone=True), info={'label': 'Deadline'}) addedAt = db.Column(db.DateTime(timezone=True)) file_name = db.Column(db.String(255)) url = db.Column(db.String(255)) priority = db.Column(db.String(255), info={ 'label': 'Priority', 'choices': [(c, c) for c in [u'ปกติ', u'ด่วน', u'ด่วนที่สุด']] }) stage = db.Column(db.String(255), info={ 'label': 'Stage', 'choices': [(c, c) for c in [u'drafting', u'ready', u'sent']] }) title = db.Column(db.String(255), info={'label': 'Title'}) summary = db.Column(db.Text(), info={'label': 'Summary'}) comment = db.Column(db.Text(), info={'label': 'Comment'}) category_id = db.Column(db.ForeignKey('doc_categories.id')) category = db.relationship(DocCategory, backref=db.backref( 'documents', lazy='dynamic', cascade='all, delete-orphan')) def get_recipients(self, round_org_id): receipt = self.doc_receipts.filter_by(round_org_id=round_org_id, doc_id=self.id).first() if receipt: return receipt.members else: return []
class JobDetails(db.Model): """ [summary] Args: UserMixin ([type]): [description] db ([type]): [description] """ __tablename__ = "jobs" job_id = db.Column(db.Integer(), nullable=False, autoincrement=True, primary_key=True) job_title = db.Column(db.String(250), nullable=True) company_name = db.Column(db.String(250), nullable=True) payscale = db.Column(db.String(250), nullable=True) location = db.Column(db.String(250), nullable=True) parent_source = db.Column(db.String(250), nullable=True) job_type = db.Column(db.String(250), nullable=True) company_type = db.Column(db.String(250), nullable=True) description = db.Column(db.String(250), nullable=True) date_posted = db.Column(db.String(250), nullable=True) active = db.Column(db.Boolean(), nullable=True)