diff --git a/datacenterlight/templates/datacenterlight/order.html b/datacenterlight/templates/datacenterlight/order.html index 61ab149a..d20bd897 100644 --- a/datacenterlight/templates/datacenterlight/order.html +++ b/datacenterlight/templates/datacenterlight/order.html @@ -74,19 +74,24 @@ {% trans "Contact" %} --> - + + @@ -95,20 +100,20 @@ -
+
-
-

{% trans "We are cutting down the costs significantly!" %}

-
- -
+
+

{% trans "We are cutting down the costs significantly!" %}

+
+ +
-
-
+
+
-
-
- {% csrf_token %} +
+ + {% csrf_token %}

{% trans "VM hosting" %}

@@ -134,7 +139,7 @@
- + {% trans "GB Storage (SSD)" %} @@ -143,16 +148,16 @@
- + {% for template in templates %} {% endfor %} - +
+ Ipv6 Only
+
-->
@@ -167,16 +172,19 @@
-
+
+
+
+
-
-

{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}

+
+

{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}

-
-

Our VMs are hosted in Glarus, Switzerland. WARNING: We are currently running in BETA mode, especially our website We hope you will not encounter any hiccups, but if you, please let us know at support@datacenterlight.ch

-
-
-
+
+

{% trans "Our VMs are hosted in Glarus, Switzerland, and our website is currently running in BETA mode. If you want more information that you did not find on our website, or if your order is more detailed, or if you encounter any technical hiccups, please contact us at support@datacenterlight.ch, our team will get in touch with you asap." %}

+
+
+
@@ -192,7 +200,7 @@
  • - {% trans "How it works" %}
  • + {% trans "What is it" %}
  • {% trans "Scale out" %}
  • @@ -216,23 +224,51 @@ - - - + + + diff --git a/datacenterlight/urls.py b/datacenterlight/urls.py index 8f35c007..f14e7186 100644 --- a/datacenterlight/urls.py +++ b/datacenterlight/urls.py @@ -1,13 +1,14 @@ from django.conf.urls import url -from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView +from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView, OrderView urlpatterns = [ url(r'^/?$', IndexView.as_view(), name='index'), url(r'^/beta-program/?$', BetaProgramView.as_view(), name='beta'), url(r'^/landing/?$', LandingProgramView.as_view(), name='landing'), - url(r'^/order/?$', PricingView.as_view(), name='pricing'), + url(r'^/pricing/?$', PricingView.as_view(), name='pricing'), + url(r'^/order/?$', OrderView.as_view(), name='order'), url(r'^/order-success/?$', SuccessView.as_view(), name='order_success'), url(r'^/beta_access?$', BetaAccessView.as_view(), name='beta_access'), ] diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 0534e057..d7b6a3e5 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -22,6 +22,56 @@ class SuccessView(TemplateView): class PricingView(TemplateView): template_name = "datacenterlight/pricing.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) + + 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 OrderView(TemplateView): + template_name = "datacenterlight/order.html" + def get(self, request, *args, **kwargs): try: manager = OpenNebulaManager() @@ -60,13 +110,13 @@ class PricingView(TemplateView): 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:pricing')) + 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:pricing')) + return HttpResponseRedirect(reverse('datacenterlight:order')) # We have valid email and name of the customer, hence send an # email to the admin