Exemplo n.º 1
0
def manage_orders(page):

    per_page = 20
    total, orders = order.query_all_orders(page, per_page)
    date_express_orders = defaultdict(lambda: defaultdict(list))

    def _get_date(dt):
        return dt.strftime("%Y-%m-%d")

    for o in orders:
        date = _get_date(o.created_time)
        date_express_orders[date][o.company].append(o)
        address = order.query_order_address(o.id)
        if address:
            o.address = address.address

    result = []
    for d, ex_ords in sorted(date_express_orders.items(), reverse=True):
        for ex, ods in sorted(ex_ords.items()):
            result.append([(d, ex),
                           sorted(ods,
                                  key=lambda x: x.created_time,
                                  reverse=True)])

    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            bs_version=3)

    return render_template(
        'management.html',
        sorted_orders=result,
        order_status_mapping=ORDER_STATUS_MAPPING,
        pagination=pagination,
    )
Exemplo n.º 2
0
Arquivo: order.py Projeto: ilcwd/hodao
def manage_orders(page):

    per_page = 20
    total, orders = order.query_all_orders(page, per_page)
    date_express_orders = defaultdict(lambda: defaultdict(list))

    def _get_date(dt):
        return dt.strftime("%Y-%m-%d")

    for o in orders:
        date = _get_date(o.created_time)
        date_express_orders[date][o.company].append(o)
        address = order.query_order_address(o.id)
        if address:
            o.address = address.address

    result = []
    for d, ex_ords in sorted(date_express_orders.items(), reverse=True):
        for ex, ods in sorted(ex_ords.items()):
            result.append([(d, ex), sorted(ods, key=lambda x: x.created_time, reverse=True)])

    pagination = Pagination(page=page, per_page=per_page, total=total, bs_version=3)

    return render_template(
        'management.html',
        sorted_orders=result,
        order_status_mapping=ORDER_STATUS_MAPPING,
        pagination=pagination,
    )
Exemplo n.º 3
0
def show_orders():
    user = flask.session['user']
    orders = order.query_orders(user)
    for o in orders:
        address = order.query_order_address(o.id)
        if address:
            o.address = address.address

    return render_template('orders.html', orders=orders)
Exemplo n.º 4
0
Arquivo: order.py Projeto: ilcwd/hodao
def show_orders():
    user = flask.session['user']
    orders = order.query_orders(user)
    for o in orders:
        address = order.query_order_address(o.id)
        if address:
            o.address = address.address

    return render_template('orders.html', orders=orders)