Merge pull request #270 from Modulos/order_now

Order now
This commit is contained in:
Levi Velázquez 2017-05-23 13:12:12 -05:00 committed by GitHub
commit f2d4e1515e
4 changed files with 55 additions and 8 deletions

View file

@ -106,7 +106,8 @@
<div class="price-calc-section">
<div class="card">
<div class="caption">
<form action="POST">
<form method="POST" action="">
{% csrf_token %}
<div class="title">
<h3>{% trans "VM hosting" %} </h3>
@ -117,7 +118,7 @@
</div>
<div class="descriptions">
<div class="description">
<p>{% trans "Based in Switzerland" %}</p>
<p>{% trans "Hosted in Switzerland" %}</p>
</div>
<div class="description">
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
@ -139,10 +140,9 @@
<div class="description select-configuration">
<select name="config" id="">
<option value="" disabled selected>Configuration</option>
<option value="CentOS 7">CentOS 7</option>
<option value="Debian 8">Debian 8</option>
<option value="Ubuntu 14.04">Ubuntu 14.04</option>
<option value="Ubuntu 16.04">Ubuntu 16.04</option>
{% for template in templates %}
<option value="{{template.id}}">{{template.name}} </option>
{% endfor %}
</select>
</div>
<input type="hidden" name="cpu">
@ -153,7 +153,7 @@
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
</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>
</div>

View file

@ -6,6 +6,7 @@ from django.contrib import messages
from django.core.urlresolvers import reverse_lazy, reverse
from utils.mailer import BaseEmail
from django.shortcuts import render
from django.shortcuts import redirect
from opennebula_api.models import OpenNebulaManager
from opennebula_api.serializers import VirtualMachineTemplateSerializer
@ -16,6 +17,50 @@ class LandingProgramView(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 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):
template_name = "datacenterlight/beta_access.html"
form_class = BetaAccessForm

View file

@ -38,6 +38,8 @@
{% trans "Login"%}
</button>
{% endbuttons %}
<input type='hidden' name='next' value='{{request.GET.next}}'/>
</form>
<span>{% trans "Don't have an account yet ? "%}<a class="unlink" href="{% url 'hosting:signup' %}">{% trans "Sign up"%}</a></span>
<br/>

View file

@ -39,7 +39,7 @@ class LoginViewMixin(FormView):
success_url = None
def get_success_url(self):
next_url = self.request.session.get('next', self.success_url)
next_url = self.request.POST.get('next', self.success_url)
return next_url
def form_valid(self, form):