Removed OrderView as we no longer use it

This commit is contained in:
M.Ravi 2017-06-15 23:36:58 +05:30
parent e897bb9c22
commit 36567071c0

View file

@ -70,78 +70,6 @@ class PricingView(TemplateView):
return redirect(reverse('hosting:payment')) 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 <support@datacenterlight.ch>',
'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): class BetaAccessView(FormView):
template_name = "datacenterlight/beta_access.html" template_name = "datacenterlight/beta_access.html"
form_class = BetaAccessForm form_class = BetaAccessForm
@ -277,13 +205,13 @@ class IndexView(CreateView):
name = name_field.clean(name) name = name_field.clean(name)
except ValidationError as err: except ValidationError as err:
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name)) 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: try:
email = email_field.clean(email) email = email_field.clean(email)
except ValidationError as err: except ValidationError as err:
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email)) 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 = { context = {
'name': name, 'name': name,