From 474e0ddc952bc288b779d01f2f6d8e684ec703c3 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 6 Jun 2017 04:22:03 +0530 Subject: [PATCH] Fixed a bug related to redirection to incorrect url on change of language. Still hardcoded (probably need a refactor of this) --- .../templates/datacenterlight/success.html | 8 +-- datacenterlight/views.py | 66 ++----------------- 2 files changed, 8 insertions(+), 66 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/success.html b/datacenterlight/templates/datacenterlight/success.html index bf7f982a..44cb619b 100644 --- a/datacenterlight/templates/datacenterlight/success.html +++ b/datacenterlight/templates/datacenterlight/success.html @@ -76,14 +76,14 @@ diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 002e912d..b8d3a3a7 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -60,24 +60,14 @@ class PricingView(TemplateView): try: name = name_field.clean(name) except ValidationError as err: - messages.error( request, - '%(value) is not a proper name.'.format(name) - ) - context = { - 'error' : 'name' - } - return render(request, self.template_name, context) + messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name)) + return reverse('datacenterlight:order') try: email = email_field.clean(email) except ValidationError as err: - messages.error( request, - '%(value) is not a proper email.'.format(email) - ) - context = { - 'error' : 'email' - } - return render(request, self.template_name, context) + messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email)) + return reverse('datacenterlight:order') # We have valid email and name of the customer, hence send an # email to the admin @@ -103,54 +93,6 @@ class PricingView(TemplateView): return render(self.request, 'datacenterlight/success.html', {}) -class OrderView(TemplateView): - template_name = "datacenterlight/order.html" - - def get(self, request, *args, **kwargs): - try: - manager = OpenNebulaManager() - templates = manager.get_templates() - - context = { - 'templates': VirtualMachineTemplateSerializer(templates, many=True).data, - } - except: - messages.error( request, - 'We could not load the VM templates due to a backend connection \ - error. Please try again in a few minutes' - ) - context = { - 'error' : 'connection' - } - - return render(request, self.template_name, context) - - - def post(self, request): - - cores = request.POST.get('cpu') - memory = request.POST.get('ram') - storage = request.POST.get('storage') - price = request.POST.get('total') - - template_id = int(request.POST.get('config')) - - manager = OpenNebulaManager() - template = manager.get_template(template_id) - - request.session['template'] = VirtualMachineTemplateSerializer(template).data - - if not request.user.is_authenticated(): - request.session['next'] = reverse('hosting:payment') - - request.session['specs'] = { - 'cpu':cores, - 'memory': memory, - 'disk_size': storage, - 'price': price, - } - - return redirect(reverse('hosting:payment')) class BetaAccessView(FormView): template_name = "datacenterlight/beta_access.html"