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,12 +571,14 @@ class OrderConfirmationView(DetailView):
response = { response = {
'status': False, 'status': False,
'redirect': "{url}#{section}".format( 'redirect': "{url}#{section}".format(
url=(reverse('show_product', kwargs={ url=(reverse(
'product_slug': kwargs['product_slug']} 'show_product',
) if 'generic_payment_details' in kwargs={'product_slug':
request.session else request.session['generic_payment_details']
['product_slug']}
) if 'generic_payment_details' in request.session else
reverse('datacenterlight:payment') reverse('datacenterlight:payment')
), ),
section='payment_error'), section='payment_error'),
'msg_title': str(_('Error.')), 'msg_title': str(_('Error.')),
'msg_body': str( 'msg_body': str(
@ -615,12 +617,16 @@ class OrderConfirmationView(DetailView):
response = { response = {
'status': False, 'status': False,
'redirect': "{url}#{section}".format( 'redirect': "{url}#{section}".format(
url=(reverse('show_product', kwargs={ url=(reverse(
'product_slug': kwargs['product_slug']} 'show_product',
) if 'generic_payment_details' in kwargs={'product_slug':
request.session else request.session
['generic_payment_details']
['product_slug']}
) if 'generic_payment_details' in
request.session else
reverse('datacenterlight:payment') reverse('datacenterlight:payment')
), ),
section='payment_error'), section='payment_error'),
'msg_title': str(_('Error.')), 'msg_title': str(_('Error.')),
'msg_body': str( 'msg_body': str(
@ -676,7 +682,7 @@ class OrderConfirmationView(DetailView):
'status': False, 'status': False,
'redirect': "{url}#{section}".format( 'redirect': "{url}#{section}".format(
url=(reverse('show_product', kwargs={ url=(reverse('show_product', kwargs={
'product_slug': kwargs['product_slug']} 'product_slug': gp_details['product_slug']}
) if 'generic_payment_details' in ) if 'generic_payment_details' in
request.session else request.session else
reverse('datacenterlight:payment') reverse('datacenterlight:payment')
@ -751,13 +757,16 @@ class OrderConfirmationView(DetailView):
response = { response = {
'status': False, 'status': False,
'redirect': "{url}#{section}".format( 'redirect': "{url}#{section}".format(
url=(reverse('show_product', kwargs={ url=(reverse(
'product_slug': kwargs['product_slug']} 'show_product',
) if 'generic_payment_details' in kwargs={'product_slug':
request.session else request.session['generic_payment_details']
['product_slug']}
) if 'generic_payment_details' in request.session else
reverse('datacenterlight:payment') reverse('datacenterlight:payment')
), ),
section='payment_error'), section='payment_error'
),
'msg_title': str(_('Error.')), 'msg_title': str(_('Error.')),
'msg_body': str( 'msg_body': str(
_('There was a payment related error.' _('There was a payment related error.'