Compare commits
No commits in common. "master" and "2.3.1" have entirely different histories.
11 changed files with 29 additions and 179 deletions
|
@ -1,9 +1,3 @@
|
|||
Next:
|
||||
* bugfix: Use correct version of django-multisite (MR #676)
|
||||
2.4.1: 2018-10-18
|
||||
* bugfix: Update pycryptodome module from 3.4 to 3.6.6 (PR #674)
|
||||
2.4: 2018-10-18
|
||||
* #5681: [hosting,dcl] Allow admin to lower minimum RAM to 512 MB (PR #672)
|
||||
2.3.1: 2018-10-17
|
||||
* bugfix: [hosting, dcl] Show VAT percent rounded to 2 decimal places in the order confirmation page (PR #673)
|
||||
2.3: 2018-10-08
|
||||
|
|
|
@ -361,4 +361,3 @@ class DCLCalculatorPluginModel(CMSPlugin):
|
|||
help_text="Write the name of the template that you need selected as"
|
||||
" default when the calculator loads"
|
||||
)
|
||||
enable_512mb_ram = models.BooleanField(default=False)
|
||||
|
|
|
@ -99,8 +99,9 @@ class DCLCalculatorPlugin(CMSPluginBase):
|
|||
context['templates'] = VMTemplate.objects.filter(
|
||||
vm_type=instance.vm_type
|
||||
).order_by('name')
|
||||
context['instance'] = instance
|
||||
context['min_ram'] = 0.5 if instance.enable_512mb_ram else 1
|
||||
context['default_selected_template'] = (
|
||||
instance.default_selected_template
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-09-29 05:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0026_dclcalculatorpluginmodel_default_selected_template'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='dclcalculatorpluginmodel',
|
||||
name='enable_512mb_ram',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
|
@ -5,10 +5,6 @@
|
|||
/* ---------------------------------------------
|
||||
Scripts initialization
|
||||
--------------------------------------------- */
|
||||
var minRam = 1;
|
||||
if(window.minRam){
|
||||
minRam = window.minRam;
|
||||
}
|
||||
var cardPricing = {
|
||||
'cpu': {
|
||||
'id': 'coreValue',
|
||||
|
@ -20,7 +16,7 @@
|
|||
'ram': {
|
||||
'id': 'ramValue',
|
||||
'value': 2,
|
||||
'min': minRam,
|
||||
'min': 1,
|
||||
'max': 200,
|
||||
'interval': 1
|
||||
},
|
||||
|
@ -44,7 +40,6 @@
|
|||
_initNavUrl();
|
||||
_initPricing();
|
||||
ajaxForms();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
|
@ -149,54 +144,21 @@
|
|||
var data = $(this).data('minus');
|
||||
|
||||
if (cardPricing[data].value > cardPricing[data].min) {
|
||||
if(data === 'ram' && String(cardPricing[data].value) === "1" && minRam === 0.5){
|
||||
cardPricing[data].value = 0.5;
|
||||
$('#ramValue').val('0.5');
|
||||
$("#ramValue").attr('step', 0.5);
|
||||
} else {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) - cardPricing[data].interval;
|
||||
}
|
||||
}
|
||||
_fetchPricing();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
||||
$('.fa-plus-circle.right').click(function(event) {
|
||||
var data = $(this).data('plus');
|
||||
if (cardPricing[data].value < cardPricing[data].max) {
|
||||
if(data === 'ram' && String(cardPricing[data].value) === "0.5" && minRam === 0.5){
|
||||
cardPricing[data].value = 1;
|
||||
$('#ramValue').val('1');
|
||||
$("#ramValue").attr('step', 1);
|
||||
} else {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) + cardPricing[data].interval;
|
||||
}
|
||||
}
|
||||
_fetchPricing();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
||||
|
||||
$('.input-price').change(function() {
|
||||
var data = $(this).attr("name");
|
||||
var input = $('input[name=' + data + ']');
|
||||
var inputValue = input.val();
|
||||
|
||||
if(data === 'ram') {
|
||||
var ramInput = $('#ramValue');
|
||||
if ($('#ramValue').data('old-value') < $('#ramValue').val()) {
|
||||
if($('#ramValue').val() === '1' && minRam === 0.5) {
|
||||
$("#ramValue").attr('step', 1);
|
||||
$('#ramValue').val('1');
|
||||
}
|
||||
} else {
|
||||
if($('#ramValue').val() === '0' && minRam === 0.5) {
|
||||
$("#ramValue").attr('step', 0.5);
|
||||
$('#ramValue').val('0.5');
|
||||
}
|
||||
}
|
||||
inputValue = $('#ramValue').val();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
}
|
||||
cardPricing[data].value = inputValue;
|
||||
cardPricing[data].value = $('input[name=' + data + ']').val();
|
||||
_fetchPricing();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,14 +9,11 @@
|
|||
window.ssdUnitPrice = {{vm_pricing.ssd_unit_price|default:0}};
|
||||
window.hddUnitPrice = {{vm_pricing.hdd_unit_price|default:0}};
|
||||
window.discountAmount = {{vm_pricing.discount_amount|default:0}};
|
||||
window.minRam = {{min_ram}};
|
||||
window.minRamErr = '{% blocktrans with min_ram=min_ram %}Please enter a value in range {{min_ram}} - 200.{% endblocktrans %}';
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<form id="order_form" method="POST" action="{{calculator_form_url}}" data-toggle="validator" role="form">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="pid" value="{{instance.id}}">
|
||||
<div class="title">
|
||||
<h3>{% trans "VM hosting" %} </h3>
|
||||
</div>
|
||||
|
@ -57,8 +54,8 @@
|
|||
<div class="form-group">
|
||||
<div class="description input">
|
||||
<i class="fa fa-minus-circle left" data-minus="ram" aria-hidden="true"></i>
|
||||
<input id="ramValue" class="input-price select-number" type="number" min="{% if min_ram == 0.5 %}0{% else %}1{% endif %}" max="200" name="ram"
|
||||
data-error="{% blocktrans with min_ram=min_ram %}Please enter a value in range {{min_ram}} - 200.{% endblocktrans %}" required step="1">
|
||||
<input id="ramValue" class="input-price select-number" type="number" min="1" max="200" name="ram"
|
||||
data-error="{% trans 'Please enter a value in range 1 - 200.' %}" required>
|
||||
<span> GB RAM</span>
|
||||
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
|
||||
</div>
|
||||
|
@ -95,7 +92,7 @@
|
|||
<select name="config">
|
||||
{% for template in templates %}
|
||||
|
||||
<option value="{{template.opennebula_vm_template_id}}" {% if template.name|lower == instance.default_selected_template|lower %}selected="selected"{% endif %}>{{template.name}}</option>
|
||||
<option value="{{template.opennebula_vm_template_id}}" {% if template.name|lower == default_selected_template|lower %}selected="selected"{% endif %}>{{template.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -27,7 +27,6 @@ from utils.forms import (
|
|||
from utils.hosting_utils import get_vm_price_with_vat
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from utils.tasks import send_plain_email_task
|
||||
from .cms_models import DCLCalculatorPluginModel
|
||||
from .forms import ContactForm
|
||||
from .models import VMTemplate, VMPricing
|
||||
from .utils import get_cms_integration, create_vm, clear_all_session_vars
|
||||
|
@ -64,7 +63,7 @@ class ContactUsView(FormView):
|
|||
sender=form.cleaned_data.get('email')
|
||||
),
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': [from_emails.get(from_page, 'support@ungleich.ch')],
|
||||
'to': [from_emails.get(from_page, 'info@ungleich.ch')],
|
||||
'body': "\n".join(
|
||||
["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
|
||||
'reply_to': [form.cleaned_data.get('email')],
|
||||
|
@ -90,29 +89,7 @@ class IndexView(CreateView):
|
|||
raise ValidationError(_('Invalid number of cores'))
|
||||
|
||||
def validate_memory(self, value):
|
||||
if 'pid' in self.request.POST:
|
||||
try:
|
||||
plugin = DCLCalculatorPluginModel.objects.get(
|
||||
id=self.request.POST['pid']
|
||||
)
|
||||
except DCLCalculatorPluginModel.DoesNotExist as dne:
|
||||
logger.error(
|
||||
str(dne) + " plugin_id: " + self.request.POST['pid']
|
||||
)
|
||||
raise ValidationError(_('Invalid calculator properties'))
|
||||
if plugin.enable_512mb_ram:
|
||||
if value % 1 == 0 or value == 0.5:
|
||||
logger.debug(
|
||||
"Given ram {value} is either 0.5 or a"
|
||||
" whole number".format(value=value)
|
||||
)
|
||||
if (value > 200) or (value < 0.5):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
else:
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
elif (value > 200) or (value < 1) or (value % 1 != 0):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
else:
|
||||
if (value > 200) or (value < 1):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
|
||||
def validate_storage(self, value):
|
||||
|
@ -128,7 +105,7 @@ class IndexView(CreateView):
|
|||
cores = request.POST.get('cpu')
|
||||
cores_field = forms.IntegerField(validators=[self.validate_cores])
|
||||
memory = request.POST.get('ram')
|
||||
memory_field = forms.FloatField(validators=[self.validate_memory])
|
||||
memory_field = forms.IntegerField(validators=[self.validate_memory])
|
||||
storage = request.POST.get('storage')
|
||||
storage_field = forms.IntegerField(validators=[self.validate_storage])
|
||||
template_id = int(request.POST.get('config'))
|
||||
|
@ -197,7 +174,7 @@ class IndexView(CreateView):
|
|||
'vat': vat,
|
||||
'vat_percent': vat_percent,
|
||||
'discount': discount,
|
||||
'total_price': round(price + vat - discount['amount'], 2),
|
||||
'total_price': price + vat - discount['amount'],
|
||||
'pricing_name': vm_pricing_name
|
||||
}
|
||||
request.session['specs'] = specs
|
||||
|
|
|
@ -157,10 +157,6 @@ $( document ).ready(function() {
|
|||
/* ---------------------------------------------
|
||||
Scripts initialization
|
||||
--------------------------------------------- */
|
||||
var minRam = 1;
|
||||
if(window.minRam){
|
||||
minRam = window.minRam;
|
||||
}
|
||||
var cardPricing = {
|
||||
'cpu': {
|
||||
'id': 'coreValue',
|
||||
|
@ -172,7 +168,7 @@ $( document ).ready(function() {
|
|||
'ram': {
|
||||
'id': 'ramValue',
|
||||
'value': 2,
|
||||
'min': minRam,
|
||||
'min': 1,
|
||||
'max': 200,
|
||||
'interval': 1
|
||||
},
|
||||
|
@ -192,54 +188,21 @@ $( document ).ready(function() {
|
|||
var data = $(this).data('minus');
|
||||
|
||||
if (cardPricing[data].value > cardPricing[data].min) {
|
||||
if(data === 'ram' && String(cardPricing[data].value) === "1" && minRam === 0.5){
|
||||
cardPricing[data].value = 0.5;
|
||||
$('#ramValue').val('0.5');
|
||||
$("#ramValue").attr('step', 0.5);
|
||||
} else {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) - cardPricing[data].interval;
|
||||
}
|
||||
}
|
||||
_fetchPricing();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
||||
$('.fa-plus-circle.right').click(function(event) {
|
||||
var data = $(this).data('plus');
|
||||
if (cardPricing[data].value < cardPricing[data].max) {
|
||||
if(data === 'ram' && String(cardPricing[data].value) === "0.5" && minRam === 0.5){
|
||||
cardPricing[data].value = 1;
|
||||
$('#ramValue').val('1');
|
||||
$("#ramValue").attr('step', 1);
|
||||
} else {
|
||||
cardPricing[data].value = Number(cardPricing[data].value) + cardPricing[data].interval;
|
||||
}
|
||||
}
|
||||
_fetchPricing();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
||||
|
||||
$('.input-price').change(function() {
|
||||
var data = $(this).attr("name");
|
||||
var input = $('input[name=' + data + ']');
|
||||
var inputValue = input.val();
|
||||
|
||||
if(data === 'ram') {
|
||||
var ramInput = $('#ramValue');
|
||||
if ($('#ramValue').data('old-value') < $('#ramValue').val()) {
|
||||
if($('#ramValue').val() === '1' && minRam === 0.5) {
|
||||
$("#ramValue").attr('step', 1);
|
||||
$('#ramValue').val('1');
|
||||
}
|
||||
} else {
|
||||
if($('#ramValue').val() === '0' && minRam === 0.5) {
|
||||
$("#ramValue").attr('step', 0.5);
|
||||
$('#ramValue').val('0.5');
|
||||
}
|
||||
}
|
||||
inputValue = $('#ramValue').val();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
}
|
||||
cardPricing[data].value = inputValue;
|
||||
cardPricing[data].value = $('input[name=' + data + ']').val();
|
||||
_fetchPricing();
|
||||
});
|
||||
}
|
||||
|
@ -273,5 +236,4 @@ $( document ).ready(function() {
|
|||
}
|
||||
|
||||
_initPricing();
|
||||
$('#ramValue').data('old-value', $('#ramValue').val());
|
||||
});
|
|
@ -32,7 +32,6 @@ from stored_messages.api import mark_read
|
|||
from stored_messages.models import Message
|
||||
from stored_messages.settings import stored_messages_settings
|
||||
|
||||
from datacenterlight.cms_models import DCLCalculatorPluginModel
|
||||
from datacenterlight.models import VMTemplate, VMPricing
|
||||
from datacenterlight.utils import create_vm, get_cms_integration
|
||||
from hosting.models import UserCardDetail
|
||||
|
@ -1199,29 +1198,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
|
|||
raise ValidationError(_('Invalid number of cores'))
|
||||
|
||||
def validate_memory(self, value):
|
||||
if 'pid' in self.request.POST:
|
||||
try:
|
||||
plugin = DCLCalculatorPluginModel.objects.get(
|
||||
id=self.request.POST['pid']
|
||||
)
|
||||
except DCLCalculatorPluginModel.DoesNotExist as dne:
|
||||
logger.error(
|
||||
str(dne) + " plugin_id: " + self.request.POST['pid']
|
||||
)
|
||||
raise ValidationError(_('Invalid calculator properties'))
|
||||
if plugin.enable_512mb_ram:
|
||||
if value % 1 == 0 or value == 0.5:
|
||||
logger.debug(
|
||||
"Given ram {value} is either 0.5 or a"
|
||||
" whole number".format(value=value)
|
||||
)
|
||||
if (value > 200) or (value < 0.5):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
else:
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
elif (value > 200) or (value < 1) or (value % 1 != 0):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
else:
|
||||
if (value > 200) or (value < 1):
|
||||
raise ValidationError(_('Invalid RAM size'))
|
||||
|
||||
def validate_storage(self, value):
|
||||
|
@ -1241,7 +1218,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
|
|||
cores = request.POST.get('cpu')
|
||||
cores_field = forms.IntegerField(validators=[self.validate_cores])
|
||||
memory = request.POST.get('ram')
|
||||
memory_field = forms.FloatField(validators=[self.validate_memory])
|
||||
memory_field = forms.IntegerField(validators=[self.validate_memory])
|
||||
storage = request.POST.get('storage')
|
||||
storage_field = forms.IntegerField(validators=[self.validate_storage])
|
||||
template_id = int(request.POST.get('config'))
|
||||
|
@ -1305,7 +1282,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
|
|||
'price': price,
|
||||
'vat': vat,
|
||||
'vat_percent': vat_percent,
|
||||
'total_price': round(price + vat - discount['amount'], 2),
|
||||
'total_price': price + vat - discount['amount'],
|
||||
'pricing_name': vm_pricing_name
|
||||
}
|
||||
|
||||
|
|
|
@ -249,8 +249,8 @@ class OpenNebulaManager():
|
|||
vm_specs = vm_specs_formatter.format(
|
||||
vcpu=int(specs['cpu']),
|
||||
cpu=0.1 * int(specs['cpu']),
|
||||
memory=(512 if specs['memory'] == 0.5 else
|
||||
1024 * int(specs['memory'])),
|
||||
memory=1024 * int(specs['memory']),
|
||||
|
||||
)
|
||||
vm_specs += """<DISK>
|
||||
<TYPE>fs</TYPE>
|
||||
|
@ -269,8 +269,8 @@ class OpenNebulaManager():
|
|||
vm_specs = vm_specs_formatter.format(
|
||||
vcpu=int(specs['cpu']),
|
||||
cpu=0.1 * int(specs['cpu']),
|
||||
memory=(512 if specs['memory'] == 0.5 else
|
||||
1024 * int(specs['memory'])),
|
||||
memory=1024 * int(specs['memory']),
|
||||
|
||||
)
|
||||
vm_specs += """<DISK>
|
||||
<TYPE>fs</TYPE>
|
||||
|
|
|
@ -34,6 +34,7 @@ django-meta==1.2
|
|||
django-meta-mixin==0.3.0
|
||||
django-model-utils==2.5
|
||||
django-mptt==0.8.4
|
||||
django-multisite==1.4.1
|
||||
django-parler==1.6.3
|
||||
django-phonenumber-field==1.1.0
|
||||
django-polymorphic==0.9.2
|
||||
|
@ -68,7 +69,7 @@ model-mommy==1.2.6
|
|||
phonenumbers==7.4.0
|
||||
phonenumberslite==7.4.0
|
||||
psycopg2==2.7.3.2
|
||||
pycryptodome==3.6.6
|
||||
pycryptodome==3.4
|
||||
pylibmc==1.5.1
|
||||
python-dateutil==2.5.3
|
||||
python-slugify==1.2.0
|
||||
|
|
Loading…
Reference in a new issue