Exemplo n.º 1
0
def order_edit(request, order):
    form = OrderForm(instance=order)
    if request.method == 'POST':
        form = OrderForm(instance=order, data=request.POST)
        if form.is_valid():
            form.save(request=request)
            messages.success(request, "Successfully updated order in {env}".format(
                env=utils.get_environment_data(request).get('label')
            ))
            return http.HttpResponseRedirect(reverse('order_home'))
    context = dict(
        form=form,
    )
    return request_to_response(request, 'order/edit.html', context)
Exemplo n.º 2
0
def order_list(request):
    orders = Order.objects.using(utils.get_environment_db(request)).all()
    form = OrderForm()
    if request.method == 'POST':
        form = OrderForm(data=request.POST)
        if form.is_valid():
            form.save(request=request)
            messages.success(request, "Successfully added order to {env}".format(
                env=utils.get_environment_data(request).get('label')
            ))
            return http.HttpResponseRedirect(reverse('order_home'))
    context = dict(
        form=form,
        orders=orders
    )
    return request_to_response(request, 'order/index.html', context)
Exemplo n.º 3
0
def home(request):
    return request_to_response(request, 'index.html')