merged master
This commit is contained in:
commit
88706b0088
30 changed files with 433 additions and 298 deletions
|
|
@ -1655,3 +1655,20 @@ a.list-group-item-danger.active:focus {
|
|||
.panel-danger > .panel-heading .badge {
|
||||
background-color: #eb4d5c;
|
||||
}
|
||||
|
||||
.checkmark {
|
||||
display: inline-block;
|
||||
}
|
||||
.checkmark:after {
|
||||
/*Add another block-level blank space*/
|
||||
content: '';
|
||||
display: block;
|
||||
/*Make it a small rectangle so the border will create an L-shape*/
|
||||
width: 25px;
|
||||
height: 60px;
|
||||
/*Add a white border on the bottom and left, creating that 'L' */
|
||||
border: solid #777;
|
||||
border-width: 0 3px 3px 0;
|
||||
/*Rotate the L 45 degrees to turn it into a checkmark*/
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,9 +155,7 @@
|
|||
function _calcPricing() {
|
||||
var total = (cardPricing['cpu'].value * 5) + (2 * cardPricing['ram'].value) + (0.6 * cardPricing['storage'].value);
|
||||
total = parseFloat(total.toFixed(2));
|
||||
|
||||
$("#total").text(total);
|
||||
$('input[name=total]').val(total);
|
||||
}
|
||||
|
||||
function form_success() {
|
||||
|
|
@ -191,4 +189,4 @@
|
|||
});
|
||||
})
|
||||
}
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from hosting.models import HostingOrder, HostingBill
|
|||
from membership.models import StripeCustomer, CustomUser
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineSerializer
|
||||
from utils.hosting_utils import get_all_public_keys
|
||||
from utils.hosting_utils import get_all_public_keys, get_or_create_vm_detail
|
||||
from utils.forms import UserBillingAddressForm
|
||||
from utils.mailer import BaseEmail
|
||||
from utils.models import BillingAddress
|
||||
|
|
@ -52,7 +52,8 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
stripe_customer_id, billing_address_data,
|
||||
billing_address_id,
|
||||
charge, cc_details):
|
||||
logger.debug("Running create_vm_task on {}".format(current_task.request.hostname))
|
||||
logger.debug(
|
||||
"Running create_vm_task on {}".format(current_task.request.hostname))
|
||||
vm_id = None
|
||||
try:
|
||||
final_price = specs.get('price')
|
||||
|
|
@ -142,9 +143,10 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
email.send()
|
||||
|
||||
if 'pass' in user:
|
||||
lang = 'en-us'
|
||||
lang = 'en-us'
|
||||
if user.get('language') is not None:
|
||||
logger.debug("Language is set to {}".format(user.get('language')))
|
||||
logger.debug(
|
||||
"Language is set to {}".format(user.get('language')))
|
||||
lang = user.get('language')
|
||||
translation.activate(lang)
|
||||
# Send notification to the user as soon as VM has been booked
|
||||
|
|
@ -174,6 +176,7 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
logger.debug("New VM ID is {vm_id}".format(vm_id=vm_id))
|
||||
if new_host is not None:
|
||||
custom_user = CustomUser.objects.get(email=user.get('email'))
|
||||
get_or_create_vm_detail(custom_user, manager, vm_id)
|
||||
if custom_user is not None:
|
||||
public_keys = get_all_public_keys(custom_user)
|
||||
keys = [{'value': key, 'state': True} for key in
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-icon"><i class="fa fa-check" aria-hidden="true"></i></div>
|
||||
<div class="modal-icon"><i class="checkmark" aria-hidden="true"></i></div>
|
||||
<h4 class="modal-title">{% trans "Request Sent" %}</h4>
|
||||
<p class="modal-text">{% trans "Thank you for your subscription! You will receive a confirmation mail from our team" %}</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="total">
|
||||
<!--<div class="description check-ip">
|
||||
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
|
||||
</div>-->
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
{% extends "datacenterlight/base.html" %}
|
||||
{% load staticfiles i18n%}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
{% block content %}
|
||||
<div class="intro-pricing">
|
||||
|
||||
<div class="intro-message">
|
||||
<h2 class="section-heading">{% trans "We are cutting down the costs significantly!" %}</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="price-calc-section">
|
||||
<div class="card">
|
||||
<img class="img-beta" src="{% static 'datacenterlight/img/beta-img.png' %}" alt="">
|
||||
<div class="caption">
|
||||
<form method="POST" action="">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="title">
|
||||
<h3>{% trans "VM hosting" %} </h3>
|
||||
</div>
|
||||
<div class="price">
|
||||
<span id="total">15</span>
|
||||
<span>CHF</span>
|
||||
<div class="price-text">
|
||||
<p>{% trans "VAT included" %}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="descriptions">
|
||||
<div class="description">
|
||||
<p>{% trans "Hosted in Switzerland" %}</p>
|
||||
</div>
|
||||
<div class="description">
|
||||
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
|
||||
<input class="input-price" type="number" min="1" max="42" id="coreValue" name="cpu">
|
||||
<span> Core</span>
|
||||
<i class="fa fa-plus-circle right" data-plus="cpu" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="description">
|
||||
<i class="fa fa-minus-circle left" data-minus="ram" aria-hidden="true"></i>
|
||||
<input id="ramValue" class="input-price" type="number" min="2" max="200" name="ram">
|
||||
<span> GB RAM</span>
|
||||
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="description">
|
||||
<i class="fa fa-minus-circle left" data-minus="storage" aria-hidden="true"></i>
|
||||
<input id="storageValue" class="input-price" type="number" min="10" max="500" step="10" name="storage">
|
||||
<span>{% trans "GB Storage (SSD)" %}</span>
|
||||
<i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="description select-configuration input">
|
||||
<label for="name">OS</label>
|
||||
<select name="config" id="">
|
||||
{% for template in templates %}
|
||||
<option value="{{template.id}}">{{template.name}} </option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="total">
|
||||
|
||||
<!-- <div class="description input">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" name="name" placeholder="Your Name">
|
||||
</div>
|
||||
<div class="description input">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email" placeholder="Your Email">
|
||||
</div> -->
|
||||
|
||||
<!--<div class="description check-ip">
|
||||
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
|
||||
</div>-->
|
||||
</div>
|
||||
<input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text">
|
||||
<h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2>
|
||||
|
||||
<div class="description">
|
||||
<p>{% 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." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
|
@ -12,6 +12,7 @@ from datacenterlight.models import VMTemplate
|
|||
from datacenterlight.tasks import create_vm_task
|
||||
from membership.models import StripeCustomer
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.hosting_utils import get_vm_price
|
||||
from utils.models import BillingAddress
|
||||
from utils.stripe_utils import StripeUtils
|
||||
|
||||
|
|
@ -94,12 +95,11 @@ class CeleryTaskTestCase(TestCase):
|
|||
cpu = specs.get('cpu')
|
||||
memory = specs.get('memory')
|
||||
disk_size = specs.get('disk_size')
|
||||
amount_to_be_charged = (cpu * 5) + (memory * 2) + (disk_size * 0.6)
|
||||
plan_name = "{cpu} Cores, {memory} GB RAM, {disk_size} GB SSD".format(
|
||||
cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
|
||||
amount_to_be_charged = get_vm_price(cpu=cpu, memory=memory,
|
||||
disk_size=disk_size)
|
||||
plan_name = StripeUtils.get_stripe_plan_name(cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
stripe_plan_id = StripeUtils.get_stripe_plan_id(cpu=cpu,
|
||||
ram=memory,
|
||||
ssd=disk_size,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from .views import IndexView, BetaProgramView, LandingProgramView, \
|
||||
BetaAccessView, PricingView, SuccessView, \
|
||||
BetaAccessView, SuccessView, \
|
||||
PaymentOrderView, OrderConfirmationView, \
|
||||
WhyDataCenterLightView, ContactUsView
|
||||
|
||||
|
|
@ -15,7 +15,6 @@ urlpatterns = [
|
|||
name='whydatacenterlight'),
|
||||
url(r'^beta-program/?$', BetaProgramView.as_view(), name='beta'),
|
||||
url(r'^landing/?$', LandingProgramView.as_view(), name='landing'),
|
||||
url(r'^pricing/?$', PricingView.as_view(), name='pricing'),
|
||||
url(r'^payment/?$', PaymentOrderView.as_view(), name='payment'),
|
||||
url(r'^order-confirmation/?$', OrderConfirmationView.as_view(),
|
||||
name='order_confirmation'),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from django.contrib import messages
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.cache import cache_control
|
||||
|
|
@ -13,10 +12,9 @@ from django.views.generic import FormView, CreateView, TemplateView, DetailView
|
|||
from datacenterlight.tasks import create_vm_task
|
||||
from hosting.models import HostingOrder
|
||||
from membership.models import CustomUser, StripeCustomer
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, \
|
||||
VMTemplateSerializer
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.forms import BillingAddressForm
|
||||
from utils.hosting_utils import get_vm_price
|
||||
from utils.mailer import BaseEmail
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from utils.tasks import send_plain_email_task
|
||||
|
|
@ -88,56 +86,6 @@ class SuccessView(TemplateView):
|
|||
return render(request, self.template_name)
|
||||
|
||||
|
||||
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 BetaAccessView(FormView):
|
||||
template_name = "datacenterlight/beta_access.html"
|
||||
form_class = BetaAccessForm
|
||||
|
|
@ -274,7 +222,6 @@ class IndexView(CreateView):
|
|||
memory_field = forms.IntegerField(validators=[self.validate_memory])
|
||||
storage = request.POST.get('storage')
|
||||
storage_field = forms.IntegerField(validators=[self.validate_storage])
|
||||
price = request.POST.get('total')
|
||||
template_id = int(request.POST.get('config'))
|
||||
template = VMTemplate.objects.filter(
|
||||
opennebula_vm_template_id=template_id).first()
|
||||
|
|
@ -334,7 +281,6 @@ class IndexView(CreateView):
|
|||
'cpu': cores,
|
||||
'memory': memory,
|
||||
'disk_size': storage,
|
||||
'price': price
|
||||
}
|
||||
|
||||
this_user = {
|
||||
|
|
@ -534,12 +480,12 @@ class OrderConfirmationView(DetailView):
|
|||
cpu = specs.get('cpu')
|
||||
memory = specs.get('memory')
|
||||
disk_size = specs.get('disk_size')
|
||||
amount_to_be_charged = (cpu * 5) + (memory * 2) + (disk_size * 0.6)
|
||||
plan_name = "{cpu} Cores, {memory} GB RAM, {disk_size} GB SSD".format(
|
||||
cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
|
||||
amount_to_be_charged = get_vm_price(cpu=cpu, memory=memory,
|
||||
disk_size=disk_size)
|
||||
specs['price'] = amount_to_be_charged
|
||||
plan_name = StripeUtils.get_stripe_plan_name(cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
stripe_plan_id = StripeUtils.get_stripe_plan_id(cpu=cpu,
|
||||
ram=memory,
|
||||
ssd=disk_size,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue