Adds “fix_errors” query to “checkout”, which allows users to have issues fix
This commit is contained in:
parent
39b130811c
commit
0340b6da20
1 changed files with 21 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue