From 5985ded36f6f515dd043e6f3cf747f274a9e6408 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 6 Oct 2018 07:31:38 +0200 Subject: [PATCH] Obtain product_slug from session Obtaining slug from kwargs won't work in OrderConfirmation page because we do not set the kwargs for that page. To resolve this, I add the product_slug to the generic_payment_details dict in the session --- datacenterlight/views.py | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index b7c606e9..19faa2d1 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -571,12 +571,14 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=(reverse('show_product', kwargs={ - 'product_slug': kwargs['product_slug']} - ) if 'generic_payment_details' in - request.session else + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in request.session else reverse('datacenterlight:payment') - ), + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -615,12 +617,16 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=(reverse('show_product', kwargs={ - 'product_slug': kwargs['product_slug']} - ) if 'generic_payment_details' in - request.session else + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session + ['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in + request.session else reverse('datacenterlight:payment') - ), + ), section='payment_error'), 'msg_title': str(_('Error.')), 'msg_body': str( @@ -676,7 +682,7 @@ class OrderConfirmationView(DetailView): 'status': False, 'redirect': "{url}#{section}".format( url=(reverse('show_product', kwargs={ - 'product_slug': kwargs['product_slug']} + 'product_slug': gp_details['product_slug']} ) if 'generic_payment_details' in request.session else reverse('datacenterlight:payment') @@ -751,13 +757,16 @@ class OrderConfirmationView(DetailView): response = { 'status': False, 'redirect': "{url}#{section}".format( - url=(reverse('show_product', kwargs={ - 'product_slug': kwargs['product_slug']} - ) if 'generic_payment_details' in - request.session else + url=(reverse( + 'show_product', + kwargs={'product_slug': + request.session['generic_payment_details'] + ['product_slug']} + ) if 'generic_payment_details' in request.session else reverse('datacenterlight:payment') - ), - section='payment_error'), + ), + section='payment_error' + ), 'msg_title': str(_('Error.')), 'msg_body': str( _('There was a payment related error.'