From 4fc11bbe17fcc03b1ed120af0b3522c9911d8f3f Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 29 Jun 2017 13:14:13 +0530 Subject: [PATCH] Made WhyDataCenterLightView a subclass of the IndexView --- datacenterlight/views.py | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 76cc54aa..205216e9 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -178,29 +178,6 @@ class BetaProgramView(CreateView): messages.add_message(self.request, messages.SUCCESS, self.success_message) return HttpResponseRedirect(self.get_success_url()) - -class WhyDataCenterLightView(CreateView): - template_name = "datacenterlight/whydatacenterlight.html" - model = BetaAccess - - @cache_control(no_cache=True, must_revalidate=True, no_store=True) - 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) - class IndexView(CreateView): template_name = "datacenterlight/index.html" model = BetaAccess @@ -321,6 +298,27 @@ class IndexView(CreateView): messages.add_message(self.request, messages.SUCCESS, self.success_message) return super(IndexView, self).form_valid(form) +class WhyDataCenterLightView(IndexView): + template_name = "datacenterlight/whydatacenterlight.html" + model = BetaAccess + + @cache_control(no_cache=True, must_revalidate=True, no_store=True) + 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) class PaymentOrderView(FormView): template_name = 'hosting/payment.html'