commit
				
					
						f2d4e1515e
					
				
			
		
					 4 changed files with 55 additions and 8 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   | ||||||
|  |  | ||||||
|  | @ -38,6 +38,8 @@ | ||||||
|                                 {% trans "Login"%} |                                 {% trans "Login"%} | ||||||
|                             </button> |                             </button> | ||||||
|                         {% endbuttons %} |                         {% endbuttons %} | ||||||
|  | 						 | ||||||
|  | 						<input type='hidden' name='next' value='{{request.GET.next}}'/>  | ||||||
|                     </form> |                     </form> | ||||||
|                     <span>{% trans "Don't have an account yet ? "%}<a class="unlink" href="{% url 'hosting:signup' %}">{% trans "Sign up"%}</a></span> |                     <span>{% trans "Don't have an account yet ? "%}<a class="unlink" href="{% url 'hosting:signup' %}">{% trans "Sign up"%}</a></span> | ||||||
|                     <br/> |                     <br/> | ||||||
|  |  | ||||||
|  | @ -39,7 +39,7 @@ class LoginViewMixin(FormView): | ||||||
|     success_url = None |     success_url = None | ||||||
| 
 | 
 | ||||||
|     def get_success_url(self): |     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 |         return next_url | ||||||
| 
 | 
 | ||||||
|     def form_valid(self, form): |     def form_valid(self, form): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue