From 36567071c0ebfa2309396984c2cfd5afed7bd7da Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 15 Jun 2017 23:36:58 +0530 Subject: [PATCH] Removed OrderView as we no longer use it --- datacenterlight/views.py | 76 ++-------------------------------------- 1 file changed, 2 insertions(+), 74 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index d23c4231..427f8c70 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -70,78 +70,6 @@ class PricingView(TemplateView): return redirect(reverse('hosting:payment')) -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 have a temporary problem to connect to our backend. \ - 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) - template_data = VirtualMachineTemplateSerializer(template).data - - name = request.POST.get('name') - email = request.POST.get('email') - name_field = forms.CharField() - email_field = forms.EmailField() - try: - 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 HttpResponseRedirect(reverse('datacenterlight:order')) - - 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 HttpResponseRedirect(reverse('datacenterlight:order')) - - context = { - 'name': name, - 'email': email, - 'cores': cores, - 'memory': memory, - 'storage': storage, - 'price': price, - 'template': template_data['name'], - } - email_data = { - 'subject': "Data Center Light Order from %s" % context['email'], - 'from_address': '(datacenterlight) datacenterlight Support ', - 'to': 'info@ungleich.ch', - 'context': context, - 'template_name': 'new_order_notification', - 'template_path': 'datacenterlight/emails/' - } - email = EmailMessage(**email_data) - email.send() - - return HttpResponseRedirect(reverse('datacenterlight:order_success')) - - class BetaAccessView(FormView): template_name = "datacenterlight/beta_access.html" form_class = BetaAccessForm @@ -277,13 +205,13 @@ class IndexView(CreateView): 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 HttpResponseRedirect(reverse('datacenterlight:order')) + return HttpResponseRedirect(reverse('datacenterlight:index')) 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 HttpResponseRedirect(reverse('datacenterlight:order')) + return HttpResponseRedirect(reverse('datacenterlight:index')) context = { 'name': name,