From 949f47d1240ee0c2190693c5edb0231843fba445 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 6 Jun 2017 04:27:38 +0530 Subject: [PATCH] Added redirection instead of rendering a template for unsuccessful order submission. Also added base_url context parameter to order notification email template --- datacenterlight/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index b8d3a3a7..33b3617b 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -61,18 +61,19 @@ class PricingView(TemplateView): name = name_field.clean(name) except ValidationError as err: messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name)) - return reverse('datacenterlight:order') + return HttpResponseRedirect(reverse('datacenterlight:pricing')) try: email = email_field.clean(email) except ValidationError as err: messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email)) - return reverse('datacenterlight:order') + return HttpResponseRedirect(reverse('datacenterlight:pricing')) # We have valid email and name of the customer, hence send an # email to the admin context = { + 'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host()), 'name': name, 'email': email, 'cores': cores, @@ -91,7 +92,7 @@ class PricingView(TemplateView): email = BaseEmail(**email_data) email.send() - return render(self.request, 'datacenterlight/success.html', {}) + return HttpResponseRedirect(reverse('datacenterlight:order_success')) class BetaAccessView(FormView):