示例#1
0
def list_orders(request, query={}):
    '''Lists orders in the specified client's queue. It defaults to
    the pending orders.'''
    client_id = request.session['client_id']
    
    if request.POST:
        query = {}
        statii = []
        for status in dao.ORDER_STATII:
            if status in request.POST:
                statii.append(status)
                query['status'] = statii
        bill_statii = []
        for status in dao.BILL_STATII:
            if status in request.POST:
                bill_statii.append(status)
                query['bill_status'] = bill_statii    
        if 'seats' in request.POST:
            query['seat_id'] = [str(i) for i in request.POST.getlist('seats')]
        if 'paths' in request.POST:
            query['path'] = [str(i) for i in request.POST.getlist('paths')]
        if 'menus' in request.POST:
            query['menu_id'] = [str(i) for i in request.POST.getlist('menus')]
        if request.POST['bill_number'] != '':
            query['bill_number'] = int(request.POST['bill_number'])
        request.session['query'] = query

    if not any(query):
        query = request.session['query']      
    orders = dao.list_orders(client_id, query)
    logger.info({'orders': orders,'modifiers':server_mods})
    return render_orders(request, client_id, orders, server_mods, is_screen=True)
示例#2
0
def screen_refresh(request):
    client_id = request.session['client_id'] 
    query = request.session['query']
    orders = dao.list_orders(client_id, query=query)
    for item in orders:
        item['status'] = item['status'].replace('_','').capitalize()

    return render_orders(request, client_id, orders, server_mods, is_screen=True)
示例#3
0
文件: views.py 项目: romerocesar/gb
def list_orders(request, client_id, query={}):
    '''Lists orders in the specified client's queue. It defaults to
    the pending orders. TODO: provide a way for the server or manager
    to filter by any combination of date, status and seat'''
    logger.debug({'client_id':client_id, 'query':query})
    # default to ORDER_PLACED for now
    if 'status' not in query:
        query['status'] = dao.ORDER_PLACED
    orders = dao.list_orders(client_id, query)
    logger.info({'orders': orders,'modifiers':server_mods})
    return render_orders(request, orders, server_mods)
示例#4
0
文件: views.py 项目: romerocesar/gb
def customer_orders(request, statii = (dao.ORDER_PLACED, dao.ORDER_PREPARING,
                                       dao.ORDER_PREPARED, dao.ORDER_SERVED, dao.BILL_REQUESTED)):
    '''Helper function that returns a list of customer orders by
    extracting the seat and location id from the session in the input
    request. It defaults to orders in one of the following statii:
    dao.ORDER_PLACED, dao.ORDER_PREPARED, dao.ORDER_SERVED,
    dao.BILL_REQUESTED. The caller can use the optional param statii
    to get a different set.'''
    seat_id = request.session['seat_id']
    client_id = request.session['client_id']
    logger.info({'seat':seat_id, 'client':client_id})
    orders = dao.list_orders(client_id, query={'seat_id':seat_id, 'status':statii})
    return orders