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="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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue