Correct pricing page redriection
This commit is contained in:
parent
df0b4f2629
commit
e6f2157b83
2 changed files with 52 additions and 7 deletions
|
@ -106,7 +106,8 @@
|
||||||
<div class="price-calc-section">
|
<div class="price-calc-section">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="caption">
|
<div class="caption">
|
||||||
<form action="POST">
|
<form method="POST" action="">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h3>{% trans "VM hosting" %} </h3>
|
<h3>{% trans "VM hosting" %} </h3>
|
||||||
|
@ -117,7 +118,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="descriptions">
|
<div class="descriptions">
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<p>{% trans "Based in Switzerland" %}</p>
|
<p>{% trans "Hosted in Switzerland" %}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
|
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
|
||||||
|
@ -139,10 +140,9 @@
|
||||||
<div class="description select-configuration">
|
<div class="description select-configuration">
|
||||||
<select name="config" id="">
|
<select name="config" id="">
|
||||||
<option value="" disabled selected>Configuration</option>
|
<option value="" disabled selected>Configuration</option>
|
||||||
<option value="CentOS 7">CentOS 7</option>
|
{% for template in templates %}
|
||||||
<option value="Debian 8">Debian 8</option>
|
<option value="{{template.id}}">{{template.name}} </option>
|
||||||
<option value="Ubuntu 14.04">Ubuntu 14.04</option>
|
{% endfor %}
|
||||||
<option value="Ubuntu 16.04">Ubuntu 16.04</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="cpu">
|
<input type="hidden" name="cpu">
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
|
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" class="btn btn-primary" value="{% trans 'Buy Now!' %}"></input>
|
<input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django.contrib import messages
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from utils.mailer import BaseEmail
|
from utils.mailer import BaseEmail
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
from opennebula_api.models import OpenNebulaManager
|
from opennebula_api.models import OpenNebulaManager
|
||||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer
|
from opennebula_api.serializers import VirtualMachineTemplateSerializer
|
||||||
|
@ -16,6 +17,50 @@ class LandingProgramView(TemplateView):
|
||||||
class PricingView(TemplateView):
|
class PricingView(TemplateView):
|
||||||
template_name = "datacenterlight/pricing.html"
|
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 could not load the VM templates due to a backend connection \
|
||||||
|
error. 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
|
||||||
|
|
||||||
|
request.session['specs'] = {
|
||||||
|
'cpu':cores,
|
||||||
|
'memory': memory,
|
||||||
|
'disk_size': storage,
|
||||||
|
'price': price,
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect(reverse('hosting:payment'))
|
||||||
|
|
||||||
|
|
||||||
class BetaAccessView(FormView):
|
class BetaAccessView(FormView):
|
||||||
template_name = "datacenterlight/beta_access.html"
|
template_name = "datacenterlight/beta_access.html"
|
||||||
form_class = BetaAccessForm
|
form_class = BetaAccessForm
|
||||||
|
|
Loading…
Reference in a new issue