Exemplo n.º 1
0
def display_customer():
    orders = models.retrieve_orders()
    customers = models.retrieve_customers()
    # Retreive data from database to display
    return render_template(
        'home.html',
        customers=customers,
        orders=orders,
    )
Exemplo n.º 2
0
def edit_order(id):
    customers = models.retrieve_customers()
    order = models.retrieve_one_order_by_id(id)
    if (order is None):
        abort(404)

    associated_customers_with_order_ids = [c['customer_id'] for c in order['customers']]
    customers = [c for c in customers if c['customer_id'] not in associated_customers_with_order_ids]

    form = OrderForm(obj=dict_to_obj(order))

    if form.validate_on_submit():
        models.update_order(id, form)
        flash_message(session, text='<strong>Success!</strong> Order was updated.')
        return redirect('/orders/' + str(id))

    return render_template('order-detail.html',  form=form, order=order, customers=customers, flash_message=flash_message(session))
Exemplo n.º 3
0
def index_customers():
    ''' Return a list of all customers '''
    # Retreive data from database to display
    customers = models.retrieve_customers()
    orders = models.retrieve_orders()
    return render_template('home.html', customers=customers, orders=orders, flash_message=flash_message(session))