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
This commit is contained in:
PCoder 2018-10-06 07:31:38 +02:00
parent 2b7d4bbef5
commit 5985ded36f

View file

@ -571,10 +571,12 @@ 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'),
@ -615,8 +617,12 @@ class OrderConfirmationView(DetailView):
response = {
'status': False,
'redirect': "{url}#{section}".format(
url=(reverse('show_product', kwargs={
'product_slug': kwargs['product_slug']}
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')
@ -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.'