From 2b7d4bbef5eb815413bf72b18038c9b0b583f0f7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 5 Oct 2018 11:10:10 +0200 Subject: [PATCH] Redirect to product page on error --- datacenterlight/views.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 0086e880..b7c606e9 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -398,7 +398,8 @@ class PaymentOrderView(FormView): "description": generic_payment_form.cleaned_data.get( 'description' ), - "product_id": product.id + "product_id": product.id, + "product_slug": product.product_slug } request.session["generic_payment_details"] = ( gp_details @@ -570,7 +571,12 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('datacenterlight:payment'), + url=(reverse('show_product', kwargs={ + 'product_slug': kwargs['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -609,7 +615,12 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('hosting:payment'), + url=(reverse('show_product', kwargs={ + 'product_slug': kwargs['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -664,8 +675,12 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=(reverse('datacenterlight:payment') + - "?type=generic"), + url=(reverse('show_product', kwargs={ + 'product_slug': kwargs['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -736,7 +751,12 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=reverse('datacenterlight:payment'), + url=(reverse('show_product', kwargs={ + 'product_slug': kwargs['product_slug']} + ) if 'generic_payment_details' in + request.session else + reverse('datacenterlight:payment') + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str(