Exemplo n.º 1
0
def basket(request):
    # do not create order automatically
    order = request.order
    if order is None:
        return HttpResponseRedirect(reverse('basket-empty'))

    if request.method == 'POST':
        formset = OrderFormset(request.POST, instance=order)

        if formset.is_valid():
            formset.save()

            if 'refresh' in request.POST:
                return HttpResponseRedirect(reverse('basket'))
            else:
                return HttpResponseRedirect(reverse('order_confirm'))
    else:
        formset = OrderFormset(instance=order)

    return {
        'order_form': get_order_form()(request),
        'formset': formset,
        'order': order,
        'keep': BASKET_OPTIONS_USE_KEEP,
        'delete': BASKET_OPTIONS_USE_DELETE,
    }
Exemplo n.º 2
0
def basket(request):
    # do not create order automatically
    order = request.order
    if request.method == 'POST':
        formset = OrderFormset(request.POST, instance=order)

        if formset.is_valid():
            formset.save()

            if 'refresh' in request.POST:
                return HttpResponseRedirect(reverse('basket'))
            else:
                return HttpResponseRedirect(reverse('order_confirm'))
    else:
        formset = OrderFormset(instance=order)

    return {
        'formset': formset,
        'order': order,
    }
Exemplo n.º 3
0
def basket(request):
    # do not create order automatically
    order = request.order
    if request.method == 'POST':
        formset = OrderFormset(request.POST, instance=order)

        if formset.is_valid():
            formset.save()

            if 'refresh' in request.POST:
                return HttpResponseRedirect(reverse('basket'))
            else:
                return HttpResponseRedirect(reverse('order_confirm'))
    else:
        formset = OrderFormset(instance=order)

    return {
        'formset': formset,
        'order': order,
    }