Removed OpenNebula code from the IndexView and code reformatted

This commit is contained in:
M.Ravi 2017-07-26 20:39:51 +02:00
parent f3cfe19e68
commit 1f58da70d4

View file

@ -1,7 +1,7 @@
from django.views.generic import FormView, CreateView, TemplateView, DetailView from django.views.generic import FormView, CreateView, TemplateView, DetailView
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from .forms import BetaAccessForm from .forms import BetaAccessForm
from .models import BetaAccess, BetaAccessVMType, BetaAccessVM from .models import BetaAccess, BetaAccessVMType, BetaAccessVM, VMTemplate
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
@ -199,20 +199,11 @@ class IndexView(CreateView):
for session_var in ['specs', 'user', 'billing_address_data']: for session_var in ['specs', 'user', 'billing_address_data']:
if session_var in request.session: if session_var in request.session:
del request.session[session_var] del request.session[session_var]
try:
manager = OpenNebulaManager() vm_templates = VMTemplate.objects.all()
templates = manager.get_templates() context = {
context = { 'templates': vm_templates
'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) return render(request, self.template_name, context)
def post(self, request): def post(self, request):
@ -329,7 +320,7 @@ class WhyDataCenterLightView(IndexView):
) )
context = { context = {
'error': 'connection' 'error': 'connection'
} }
return render(request, self.template_name, context) return render(request, self.template_name, context)
@ -462,9 +453,9 @@ class OrderConfirmationView(DetailView):
template_id=vm_template_id, template_id=vm_template_id,
specs=specs, specs=specs,
vm_name="{email}-{template_name}-{date}".format( vm_name="{email}-{template_name}-{date}".format(
email=user.get('email'), email=user.get('email'),
template_name=template.get('name'), template_name=template.get('name'),
date=int(datetime.now().strftime("%s"))) date=int(datetime.now().strftime("%s")))
) )
# Create a Hosting Order # Create a Hosting Order