Merge tag '2.10.2' into branch-2.10.3b
Introduce base price for VMs and let admins add stripe_coupon_id
This commit is contained in:
commit
580960548e
12 changed files with 62 additions and 24 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from cms.plugin_base import CMSPluginBase
|
||||
from cms.plugin_pool import plugin_pool
|
||||
from django.conf import settings
|
||||
|
||||
from .cms_models import (
|
||||
DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel,
|
||||
|
|
@ -100,6 +101,7 @@ class DCLCalculatorPlugin(CMSPluginBase):
|
|||
vm_type=instance.vm_type
|
||||
).order_by('name')
|
||||
context['instance'] = instance
|
||||
context['vm_base_price'] = settings.VM_BASE_PRICE
|
||||
context['min_ram'] = 0.5 if instance.enable_512mb_ram else 1
|
||||
return context
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2020-02-04 03:16
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0030_dclnavbarpluginmodel_show_non_transparent_navbar_always'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='vmpricing',
|
||||
name='stripe_coupon_id',
|
||||
field=models.CharField(blank=True, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -54,6 +54,7 @@ class VMPricing(models.Model):
|
|||
discount_amount = models.DecimalField(
|
||||
max_digits=6, decimal_places=2, default=0
|
||||
)
|
||||
stripe_coupon_id = models.CharField(max_length=255, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
display_str = self.name + ' => ' + ' - '.join([
|
||||
|
|
|
|||
|
|
@ -225,8 +225,8 @@
|
|||
}
|
||||
var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
|
||||
(cardPricing['ram'].value * window.ramUnitPrice) +
|
||||
(cardPricing['storage'].value * window.ssdUnitPrice) -
|
||||
window.discountAmount;
|
||||
(cardPricing['storage'].value * window.ssdUnitPrice) +
|
||||
window.vmBasePrice - window.discountAmount;
|
||||
total = parseFloat(total.toFixed(2));
|
||||
$("#total").text(total);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="price-calc-section">
|
||||
<div class="card">
|
||||
{% include "datacenterlight/includes/_calculator_form.html" with vm_pricing=instance.pricing %}
|
||||
{% include "datacenterlight/includes/_calculator_form.html" with vm_pricing=instance.pricing vm_base_price=vm_base_price %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
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.vmBasePrice = {{vm_base_price|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>
|
||||
|
|
|
|||
|
|
@ -678,9 +678,9 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
vm_specs["vat_percent"] = vat_percent
|
||||
vm_specs["vat_validation_status"] = request.session["vat_validation_status"] if "vat_validation_status" in request.session else ""
|
||||
vm_specs["vat_country"] = user_vat_country
|
||||
vm_specs["price_with_vat"] = round_up(price * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||
vm_specs["price_after_discount"] = round_up(price - discount['amount'], 2)
|
||||
vm_specs["price_after_discount_with_vat"] = round_up((price - discount['amount']) * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||
vm_specs["price_with_vat"] = round(price * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||
vm_specs["price_after_discount"] = round(price - discount['amount'], 2)
|
||||
vm_specs["price_after_discount_with_vat"] = round((price - discount['amount']) * (1 + vm_specs["vat_percent"] * 0.01), 2)
|
||||
discount["amount_with_vat"] = round(vm_specs["price_with_vat"] - vm_specs["price_after_discount_with_vat"], 2)
|
||||
vm_specs["total_price"] = vm_specs["price_after_discount_with_vat"]
|
||||
vm_specs["discount"] = discount
|
||||
|
|
@ -933,11 +933,11 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
subscription_result = stripe_utils.subscribe_customer_to_plan(
|
||||
stripe_api_cus_id,
|
||||
[{"plan": stripe_plan.get('response_object').stripe_plan_id}],
|
||||
coupon='ipv6-discount-8chf' if (
|
||||
'name' in discount and
|
||||
discount['name'] is not None and
|
||||
'ipv6' in discount['name'].lower()
|
||||
) else "",
|
||||
coupon=(discount['stripe_coupon_id']
|
||||
if 'name' in discount and
|
||||
'ipv6' in discount['name'].lower() and
|
||||
discount['stripe_coupon_id']
|
||||
else ""),
|
||||
tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [],
|
||||
)
|
||||
stripe_subscription_obj = subscription_result.get('response_object')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue