class Order(Model): __tablename__ = 'order' order_id = db.Column(db.Integer, primary_key=True, autoincrement=True) buyer_id = db.Column(db.Integer, db.ForeignKey('buyer.buyer_id'), nullable=True) buyer = db.relationship('Buyer', backref=db.backref('orders', lazy=True)) supplier_id = db.Column(db.Integer, db.ForeignKey('supplier.supplier_id'), nullable=True) supplier = db.relationship('Supplier', backref=db.backref('orders', lazy=True)) date_created = db.Column(db.Date) time_created = db.Column(db.Time) accepted = db.Column(db.Boolean) status = db.Column(db.String(45)) price = db.Column(db.Float) rate = db.Column(db.Integer) comment = db.Column(db.String(255)) ship_price_buyer = db.Column(db.Float) ship_price_supplier = db.Column(db.Float) ship_price = db.Column(db.Float) def __init__(self, buyer_id=None, supplier_id=None, date_created=None, time_created=None, accepted=None, status=None, price=None, rate=None, comment=None, ship_price_buyer=None, ship_price_supplier=None, ship_price=None): self.buyer_id = buyer_id self.supplier_id = supplier_id self.date_created = date_created self.time_created = time_created self.accepted = accepted self.status = status self.price = price self.rate = rate self.comment = comment self.ship_price_buyer = ship_price_buyer self.ship_price_supplier = ship_price_supplier self.ship_price = ship_price
class History(Model): __tablename__ = "history" history_id = db.Column(db.Integer, primary_key=True, autoincrement=True) user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('histories', lazy=True)) description = db.Column(db.String, nullable=False) date_created = db.Column(db.Date, nullable=False) time_created = db.Column(db.Time, nullable=False) def __init__(self, user_id, description, date_created=None, time_created=None): self.user_id = user_id self.description = description if date_created is None: date_created = datetime.datetime.today().date() if time_created is None: time_created = datetime.datetime.now().time() self.date_created = date_created self.time_created = time_created
class TypeOfService(db.Model): __tablename__ = 'types_of_service' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(50), nullable=False) description = db.Column(db.Text(), nullable=False) id_service_form = db.relationship('ServiceForm',secondary='type_service_form', backref=db.backref('types_of_service', lazy='dynamic')) def __str__(self): return self.name
class SubCategory(Model): __tablename__ = 'SUB_CATEGORY' subCategooryID = db.Column(db.Integer, primary_key=True, autoincrement=True) subCategoryName = db.Column(db.String(50), nullable=False) categoryID = db.Column(db.Integer, db.ForeignKey('CATEGORY.categoryID'), nullable=False) category = db.relationship('Category', backref=db.backref('SUB_CATEGORY', lazy=True))
class Carpooling(Model): __tablename__ = 'carpooling' carpooling_id = db.Column(db.Integer, primary_key=True, autoincrement=True) driver_id = db.Column(db.Integer, db.ForeignKey('driver.driver_id'), nullable=True) driver = db.relationship('Driver', backref=db.backref('carpoolings', lazy=True)) passenger_id = db.Column(db.Integer, db.ForeignKey('passenger.passenger_id'), nullable=True) passenger = db.relationship('Passenger', backref=db.backref('carpoolings', lazy=True)) date_created = db.Column(db.Date) time_created = db.Column(db.Time) accepted = db.Column(db.Boolean) status = db.Column(db.String(45)) price_offer_passenger = db.Column(db.Float) price_offer_driver = db.Column(db.Float) price = db.Column(db.Float) rate = db.Column(db.Integer) comment = db.Column(db.String(255)) def __init__(self, driver_id, passenger_id, date_created, time_created, accepted, status, price_offer_passenger, price_offer_driver, price, rate, comment): self.driver_id = driver_id self.passenger_id = passenger_id self.date_created = date_created self.time_created = time_created self.accepted = accepted self.status = status self.price_offer_driver = price_offer_driver self.price_offer_passenger = price_offer_passenger self.price = price self.rate = rate self.comment = comment
class Account(Model): __tablename__ = "account" account_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # relationship user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('accounts', lazy=True)) account_name = db.Column(db.String(45)) account_number = db.Column(db.String(45)) balance = db.Column(db.Float) date_created = db.Column(db.Date) card_number = db.Column(db.String(45)) card_type = db.Column(db.String(45)) card_expired_date = db.Column(db.Date) card_security_number = db.Column(db.String(45)) bank_name = db.Column(db.String(255)) bank_swift = db.Column(db.String(255)) card_holder_name = db.Column(db.String(80)) def __init__(self, user_id, account_name=None, account_number=None, balance=None, date_created=None, card_number=None, card_type=None, card_expired_date=None, card_security_number=None, bank_name=None, bank_swift=None, card_holder_name=None): self.user_id = user_id self.account_name = account_name self.account_number = account_number self.balance = balance self.date_created = date_created self.card_number = card_number self.card_type = card_type self.card_expired_date = card_expired_date self.card_security_number = card_security_number self.bank_name = bank_name self.bank_swift = bank_swift self.card_holder_name = card_holder_name def __repr__(self): pass
class Organization(db.Model): __tablename__ = 'organizations' # 1 регистрационный номер учетной записи id = db.Column(db.Integer(), primary_key=True) # 2 название организации name = db.Column(db.Text(), nullable=False) # 3 дата гос. регистрации юр. лица date_registration = db.Column(db.DateTime(), nullable=False) # 4 организационно-правовая форма opf = db.Column(db.Text(), nullable=False) # 5 адреса, телефон, эл. почта contacts = db.Column(db.Text(), nullable=False) # 6 ФИО руководителя name_boss = db.Column(db.Text(), nullable=False) # 7 информация о лицензии организации license = db.Column(db.Text(), nullable=False) # 8 формы обслуживания form_service = db.relationship('ServiceForm', secondary='organization_service_form', backref=db.backref('organizations', lazy='dynamic')) # 9 направления реабилитации или абилитации direction_of_rehabilitation = db.Column(db.Text(), nullable=False) # 10 перечень оказываемых услуг, наличие специалистов, наличие технических средств, реабилитационные программы resources = db.Column(db.Text(), nullable=False) # 11 общее количество мест для реабил. услуг total_seats = db.Column(db.Integer(), nullable=False) # 11 количество свободных мест для реабил. услуг free_seats = db.Column(db.Integer(), nullable=False) # 12 информация о результатх, проведенных проверок result_checks = db.Column(db.Text(), nullable=False) # 13 информация об опыте работы за последние 5 лет work_experience = db.Column(db.Text(), nullable=False) # 14 ведомственная принадлежность departmental_affiliation = db.Column(db.Text(), nullable=False) # 15 вышестоящая организация parent_organization = db.Column(db.Text(), nullable=False) # 16 другая информация, определнная региональными нормативными актами other_information = db.Column(db.Text(), nullable=False) def __str__(self): return self.name
class Passenger(Model): __tablename__ = "passenger" passenger_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # the relationship user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('passengers', lazy=True)) current_place = db.Column(db.String(255)) current_country = db.Column(db.String(80)) current_city = db.Column(db.String(80)) current_street = db.Column(db.String(80)) current_geo_long = db.Column(db.Float) current_geo_lat = db.Column(db.Float) from_place = db.Column(db.String(255)) from_country = db.Column(db.String(80)) from_city = db.Column(db.String(80)) from_street = db.Column(db.String(80)) from_geo_long = db.Column(db.Float) from_geo_lat = db.Column(db.Float) to_place = db.Column(db.String(255)) to_country = db.Column(db.String(80)) to_city = db.Column(db.String(80)) to_street = db.Column(db.String(80)) to_geo_long = db.Column(db.Float) to_geo_lat = db.Column(db.Float) go_date = db.Column(db.Date) go_time = db.Column(db.String(255)) number_people = db.Column(db.Integer) radius = db.Column(db.Float) chat_available = db.Column(db.Boolean) price_offer = db.Column(db.Float)
class Supplier(Model): __tablename__ = "supplier" supplier_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # relationship user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('suppliers', lazy=True)) buying_place = db.Column(db.String(255)) buying_country = db.Column(db.String(255)) buying_city = db.Column(db.String(255)) buying_street = db.Column(db.String(255)) buying_geo_long = db.Column(db.Float) buying_geo_lat = db.Column(db.Float) buying_date = db.Column(db.Date) # date when supplier can come to buying place buying_time = db.Column(db.Time) # time (expected) when supplier can come to buying place ship_place = db.Column(db.String(255)) ship_country = db.Column(db.String(255)) ship_city = db.Column(db.String(255)) ship_street = db.Column(db.String(255)) ship_geo_long = db.Column(db.Float) ship_geo_lat = db.Column(db.Float) ship_date = db.Column(db.Date) ship_time = db.Column(db.Time) # current_place = db.Column(db.String(255)) # current_country = db.Column(db.String(255)) # current_city = db.Column(db.String(255)) # current_street = db.Column(db.String(255)) # current_geo_long = db.Column(db.Float) # current_geo_lat = db.Column(db.Float) # search_radius = db.Column(db.Float) # search_place = db.Column(db.String(255)) # delivery_date = db.Column(db.Date) # delivery_time = db.Column(db.Time) ship_radius = db.Column(db.Float) car_size = db.Column(db.Integer) shipping_cost = db.Column(db.Float) def __init__(self, user_id, buying_place=None, buying_country=None, buying_city=None, buying_street=None, buying_geo_long=None, buying_geo_lat=None, buying_date=None, buying_time=None, ship_place=None, ship_country=None, ship_city=None, ship_street=None, ship_geo_long=None, ship_geo_lat=None, ship_date=None, ship_time=None, ship_radius=None, car_size=None, shipping_cost=None): self.user_id = user_id self.buying_place = buying_place self.buying_country = buying_country self.buying_city = buying_city self.buying_street = buying_street self.buying_geo_long = buying_geo_long self.buying_geo_lat = buying_geo_lat self.buying_date = buying_date self.buying_time = buying_time self.ship_place = ship_place self.ship_country = ship_country self.ship_city = ship_city self.ship_street = ship_street self.ship_geo_long = ship_geo_long self.ship_geo_lat = ship_geo_lat self.ship_date = ship_date self.ship_time = ship_time self.ship_radius = ship_radius self.car_size = car_size self.shipping_cost = shipping_cost
class Product(Model): __tablename__ = 'product' product_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # order_id = db.Column(db.Integer, db.ForeignKey('buyer.order_id'), nullable=False) # buyer = db.relationship('Buyer', backref=db.backref('products', lazy=True)) order_id = db.Column(db.Integer, db.ForeignKey('order.order_id'), nullable=False) order = db.relationship('Order', backref=db.backref('products', lazy=True)) product_name = db.Column(db.String(255), nullable=True) product_price = db.Column(db.Float, nullable=True) qrcode = db.Column(db.String(45)) barcode = db.Column(db.String(45)) vendor_name = db.Column(db.String(80)) photo_path = db.Column(db.String(255)) photo = db.Column(db.Text) store_name = db.Column(db.String(255)) store_address = db.Column(db.String(255)) category = db.Column(db.String(80)) volume = db.Column(db.String(255)) unit = db.Column(db.String(45)) amount = db.Column(db.Integer) def __init__(self, order_id, product_name, product_price, qrcode=None, barcode=None, vendor_name=None, photo_path=None, photo=None, store_name=None, store_address=None, category=None, volume=None, unit=None, amount=None): self.order_id = order_id self.product_name = product_name self.product_price = product_price self.qrcode = qrcode self.barcode = barcode self.vendor_name = vendor_name self.photo_path = photo_path self.photo = photo self.store_name = store_name self.store_address = store_address self.category = category self.volume = volume self.unit = unit self.amount = amount
class Buyer(Model): __tablename__ = "buyer" buyer_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # relationship user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('buyers', lazy=True)) buying_place = db.Column(db.String(255)) buying_country = db.Column(db.String(80)) buying_city = db.Column(db.String(80)) buying_street = db.Column(db.String(80)) buying_geo_long = db.Column(db.Float) buying_geo_lat = db.Column(db.Float) buying_time = db.Column(db.Time) buying_date = db.Column(db.Date) ship_place = db.Column(db.String(255)) ship_country = db.Column(db.String(80)) ship_city = db.Column(db.String(80)) ship_street = db.Column(db.String(80)) ship_geo_long = db.Column(db.Float) ship_geo_lat = db.Column(db.Float) ship_time = db.Column(db.Time) ship_date = db.Column(db.Date) current_address = db.Column(db.String(80)) current_country = db.Column(db.String(80)) current_city = db.Column(db.String(80)) current_street = db.Column(db.String(80)) current_geo_long = db.Column(db.Float) current_geo_lat = db.Column(db.Float) search_radius = db.Column(db.Float) search_place = db.Column(db.String(255)) shopping_cost = db.Column(db.Float) shipping_cost = db.Column(db.Float) def __init__(self, user_id, buying_place=None, buying_country=None, buying_city=None, buying_street=None, buying_geo_long=None, buying_geo_lat=None, buying_time=None, buying_date=None, ship_place=None, ship_country=None, ship_city=None, ship_street=None, ship_geo_long=None, ship_geo_lat=None, ship_time=None, ship_date=None, current_address=None, current_country=None, current_city=None, current_street=None, current_geo_long=None, current_geo_lat=None, search_radius=None, search_place=None, shopping_cost=None, shipping_cost=None): self.user_id = user_id self.buying_place = buying_place self.buying_country = buying_country self.buying_city = buying_city self.buying_street = buying_street self.buying_geo_long = buying_geo_long self.buying_geo_lat = buying_geo_lat self.buying_date = buying_date self.buying_time = buying_time self.ship_place = ship_place self.ship_country = ship_country self.ship_city = ship_city self.ship_street = ship_street self.ship_geo_long = ship_geo_long self.ship_geo_lat = ship_geo_lat self.ship_date = ship_date self.ship_time = ship_time self.current_address = current_address self.current_country = current_country self.current_city = current_city self.current_street = current_street self.current_geo_long = current_geo_long self.current_geo_lat = current_geo_lat self.search_radius = search_radius self.search_place = search_place self.shopping_cost = shopping_cost self.shipping_cost = shipping_cost # def get_shopping_cost(self): # cost = 0 # query = Product.query.with_parent(self).all() # for product in query: # product_price = product.product_price # cost = cost + product_price # return cost def get_shopping_cost_all_order(self): cost = 0 query = Order.query.with_parent(self).all() if query is None or len(query) == 0: return cost for order in query: order_price = order.price cost = cost + order_price return cost def get_shopping_cost_order(self, order_id): order = Order.query.filter_by(order_id=order_id).first() if order is None: return None else: return order.price
class Driver(Model): __tablename__ = "driver" driver_id = db.Column(db.Integer, primary_key=True, autoincrement=True) # relationship user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) user = db.relationship('User', backref=db.backref('drivers', lazy=True)) current_place = db.Column(db.String(255)) current_country = db.Column(db.String(80)) current_city = db.Column(db.String(80)) current_street = db.Column(db.String(80)) current_geo_long = db.Column(db.Float) current_geo_lat = db.Column(db.Float) target_place = db.Column(db.String(255)) target_country = db.Column(db.String(80)) target_city = db.Column(db.String(80)) target_street = db.Column(db.String(80)) target_geo_long = db.Column(db.Float) target_geo_lat = db.Column(db.Float) go_date = db.Column(db.Date) go_time = db.Column(db.String(255)) arrive_date = db.Column(db.Date) arrive_time = db.Column(db.String(255)) pickup_distance = db.Column(db.Float) pickup_place = db.Column(db.String(80)) pickup_country = db.Column(db.String(80)) pickup_city = db.Column(db.String(80)) pickup_address = db.Column(db.String(80)) pickup_geo_long = db.Column(db.Float) pickup_geo_lat = db.Column(db.Float) price_offer = db.Column(db.Float) chat_available = db.Column(db.Boolean) car_model = db.Column(db.String(80)) car_color = db.Column(db.String(80)) car_plate = db.Column(db.String(80)) car_number_seat = db.Column(db.Integer) number_people = db.Column(db.Integer) radius = db.Column(db.Float) def __init__(self, user_id, current_place=None, current_country=None, current_city=None, current_street=None, current_geo_long=None, current_geo_lat=None, target_place=None, target_country=None, target_city=None, target_street=None, target_geo_long=None, target_geo_lat=None, go_date=None, go_time=None, arrive_date=None, arrive_time=None, pickup_distance=None, pickup_place=None, pickup_country=None, pickup_city=None, pickup_address=None, pickup_geo_long=None, pickup_geo_lat=None, price_offer=None, chat_available=None, car_model=None, car_color=None, car_plate=None, car_number_seat=None, number_people=None, radius=None): self.user_id = user_id self.current_place = current_place self.current_country = current_country self.current_city = current_city self.current_street = current_street self.current_geo_long = current_geo_long self.current_geo_lat = current_geo_lat self.target_place = target_place self.target_country = target_country self.target_city = target_city self.target_street = target_street self.target_geo_long = target_geo_long self.target_geo_lat = target_geo_lat self.go_date = go_date self.go_time = go_time self.arrive_date = arrive_date self.arrive_time = arrive_time self.pickup_distance = pickup_distance self.pickup_place = pickup_place self.pickup_country = pickup_country self.pickup_city = pickup_city self.pickup_address = pickup_address self.pickup_geo_long = pickup_geo_long self.pickup_geo_lat = pickup_geo_lat self.price_offer = price_offer self.chat_available = chat_available self.car_model = car_model self.car_color = car_color self.car_plate = car_plate self.car_number_seat = car_number_seat self.number_people = number_people self.radius = radius