コード例 #1
0
from Application.database.initialize_database import Base, session
from Application.database.sqlalchemy_imports import *
from Application.utils import LazyLoader
pdts = LazyLoader("Application.database.models.product_models.products")
from datetime import datetime
import pytz

ni_timezone = pytz.timezone('Africa/Nairobi')
timezone = pytz.timezone("Africa/Kampala")


def all_top_selling_pdts_generator(data_list):
    _date = datetime.now(ni_timezone)
    current_time = _date.astimezone(timezone)
    if data_list:
        for product in data_list:
            pdt = pdts.Products.read_product(id=product.product_id)
            if pdt:
                if pdt.resturant.approved:
                    if pdt.approved and pdt.suspend != True:
                        _start_date = ni_timezone.localize(
                            pdt.resturant.operation_start_time)
                        _end_date = ni_timezone.localize(
                            pdt.resturant.operation_stop_time)
                        operation_start_time = _start_date.astimezone(timezone)
                        operation_stop_time = _end_date.astimezone(timezone)
                        if current_time.hour >= operation_start_time.hour and current_time.hour <= operation_stop_time.hour:
                            pdt = pdt.serialize()
                            pdt["available"] = True
                            yield pdt
                        else:
コード例 #2
0
from Application.database.initialize_database import Base, session
from Application.database.sqlalchemy_imports import (
    Column, String, Integer, BigInteger, Integer, DateTime, ForeignKey,
    relationship, Boolean, func, hybrid_property
) 
from Application.utils import LazyLoader
from datetime import datetime
from Application.flask_imports import Markup

#lazy loading dependency modules
shp = LazyLoader("Application.database.models.business_models")
pdts = LazyLoader("Application.database.models.product_models.products")

class Cart(Base):
    __tablename__ = "cart"

    id = Column(Integer, primary_key=True)
    product_id = Column(Integer)
    product_image = Column(String(50), nullable=False)
    product_name = Column(String(50), nullable=False)
    quantity = Column(BigInteger, nullable=False)
    unit_price = Column(BigInteger, nullable=False)
    commision_amount = Column(BigInteger, nullable=True)
    served_with = Column(String(1000), nullable=False, default="none")
    date = Column(DateTime, default=datetime.now(), nullable=False)
    is_ordered = Column(Boolean, default=False, nullable=False)
    customer_id = Column(Integer, ForeignKey("customer.id"), index=True, nullable=False)
    customer = relationship("Customer", backref="cart")
    order_id = Column(Integer, ForeignKey("order.id"), index=True)
    order = relationship("Order", backref="cart")
    free_delivery = Column(Boolean, nullable=False, default=False)
コード例 #3
0
ファイル: products.py プロジェクト: Byenkya/ClickEat-Code
                                                     BigInteger, func, Boolean,
                                                     Float)
from Application.database.initialize_database import Base, session
from Application.utils import LazyLoader
from random import sample
from Application.flask_imports import jsonify
from Application.database.models import HomeImages
import math
from datetime import datetime
import pytz

ni_timezone = pytz.timezone('Africa/Nairobi')
timezone = pytz.timezone("Africa/Kampala")

#lazy loading dependencies.
brnd = LazyLoader("Application.database.models.product_models.brand")
pdtds = LazyLoader(
    "Application.database.models.product_models.product_discounts")
subCat = LazyLoader("Application.database.models.product_models.subcategory")
cat = LazyLoader("Application.database.models.product_models.category")


# generators
def food_snacks_generator(data_list):
    _date = datetime.now(ni_timezone)
    current_time = _date.astimezone(timezone)
    for product in data_list:
        if product.resturant.approved:
            if product.resturant.favourite and product.approved and product.suspend != True:
                _start_date = ni_timezone.localize(
                    product.resturant.operation_start_time)
コード例 #4
0
ファイル: order.py プロジェクト: Byenkya/ClickEat-Code
from Application.database.initialize_database import Base, session
from Application.database.sqlalchemy_imports import (Column, Integer, String,
                                                     Boolean, BigInteger,
                                                     DateTime, ForeignKey,
                                                     relationship, func,
                                                     lazyload, desc, and_)
from Application.flask_imports import current_app, flash, abort, jsonify
from Application.utils import LazyLoader
from Application.utils.email import order_cancelled_email, order_placed_email, order_receipt_email, customer_care_email
from Application.helpers import ReferenceGenerator

from datetime import datetime

#lazy laoding of dependencies
customer = LazyLoader("Application.database.models.customer_models.customer")
customer_addresses = LazyLoader(
    "Application.database.models.customer_models.customer_addresses")
pym = LazyLoader("Application.database.models.payment_models")
pdts = LazyLoader("Application.database.models.product_models")
delivery_detials = LazyLoader(
    "Application.database.models.order_models.delivery_details")
sales = LazyLoader("Application.database.models.product_models.sales")
cart = LazyLoader("Application.database.models.product_models.cart")

#click_mysql_password = 5FJc_?]-JSCsOMfDCcU1xhJGTsiSN^pr


class Order(Base):
    __tablename__ = "order"

    id = Column(Integer, primary_key=True)
コード例 #5
0
from Application.database.initialize_database import Base, session
from Application.database.sqlalchemy_imports import (Column, Integer, String,
                                                     DateTime, Boolean, func)
from Application.utils import LazyLoader
from datetime import datetime

dd = LazyLoader("Application.database.models.order_models.delivery_details")


class Courier(Base):
    __tablename__ = "courier"

    id = Column(Integer, primary_key=True)
    courier_name = Column(String(100), nullable=False)
    driver_license_number = Column(String(30), unique=True, nullable=False)
    contact = Column(String(13), unique=True, nullable=False)
    second_contact = Column(String(13), unique=True, nullable=False)
    email = Column(String(30), nullable=False)
    address = Column(String(500), nullable=False)
    district = Column(String(50), nullable=False)
    vehicle_type = Column(String(20), nullable=False)
    vehicle_license_plate_number = Column(String(20), nullable=False)
    courier_pic = Column(String(50), nullable=False)
    local_council_1_letter = Column(String(50), nullable=False)
    agreement_letter = Column(String(50), nullable=False)
    national_id_number = Column(String(20), nullable=False)
    registration_date = Column(DateTime,
                               default=datetime.now(),
                               nullable=False)
    is_available = Column(Boolean, default=True, nullable=False)