Adds “fix_errors” query to “checkout”, which allows users to have issues fix

This commit is contained in:
Christopher Neugebauer 2016-04-06 14:34:16 +10:00
parent 39b130811c
commit 0340b6da20

View file

@ -377,10 +377,30 @@ def checkout(request):
invoice. '''
current_cart = CartController.for_user(request.user)
if "fix_errors" in request.GET and request.GET["fix_errors"] == "true":
current_cart.fix_simple_errors()
try:
current_invoice = InvoiceController.for_cart(current_cart.cart)
except ValidationError as ve:
return checkout_errors(request, ve)
return redirect("invoice", current_invoice.invoice.id)
def checkout_errors(request, errors):
error_list = []
for error in errors.error_list:
if isinstance(error, tuple):
error = error[1]
error_list.append(error)
data = {
"error_list": error_list,
}
return render(request, "registrasion/checkout_errors.html", data)
@login_required
def invoice(request, invoice_id):