Set vm base price in js also

This commit is contained in:
PCoder 2020-02-03 12:07:50 +05:30
parent 00b434efb9
commit e6de90e431
5 changed files with 8 additions and 5 deletions

View file

@ -1,5 +1,6 @@
from cms.plugin_base import CMSPluginBase from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool from cms.plugin_pool import plugin_pool
from django.conf import settings
from .cms_models import ( from .cms_models import (
DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel, DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel,
@ -100,6 +101,7 @@ class DCLCalculatorPlugin(CMSPluginBase):
vm_type=instance.vm_type vm_type=instance.vm_type
).order_by('name') ).order_by('name')
context['instance'] = instance context['instance'] = instance
context['vm_base_price'] = settings.VM_BASE_PRICE
context['min_ram'] = 0.5 if instance.enable_512mb_ram else 1 context['min_ram'] = 0.5 if instance.enable_512mb_ram else 1
return context return context

View file

@ -225,8 +225,8 @@
} }
var total = (cardPricing['cpu'].value * window.coresUnitPrice) + var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
(cardPricing['ram'].value * window.ramUnitPrice) + (cardPricing['ram'].value * window.ramUnitPrice) +
(cardPricing['storage'].value * window.ssdUnitPrice) - (cardPricing['storage'].value * window.ssdUnitPrice) +
window.discountAmount; window.vmBasePrice - window.discountAmount;
total = parseFloat(total.toFixed(2)); total = parseFloat(total.toFixed(2));
$("#total").text(total); $("#total").text(total);
} }

View file

@ -1,5 +1,5 @@
<div class="price-calc-section"> <div class="price-calc-section">
<div class="card"> <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>
</div> </div>

View file

@ -9,6 +9,7 @@
window.ssdUnitPrice = {{vm_pricing.ssd_unit_price|default:0}}; window.ssdUnitPrice = {{vm_pricing.ssd_unit_price|default:0}};
window.hddUnitPrice = {{vm_pricing.hdd_unit_price|default:0}}; window.hddUnitPrice = {{vm_pricing.hdd_unit_price|default:0}};
window.discountAmount = {{vm_pricing.discount_amount|default:0}}; window.discountAmount = {{vm_pricing.discount_amount|default:0}};
window.vmBasePrice = {{vm_base_price|default:0}};
window.minRam = {{min_ram}}; window.minRam = {{min_ram}};
window.minRamErr = '{% blocktrans with min_ram=min_ram %}Please enter a value in range {{min_ram}} - 200.{% endblocktrans %}'; window.minRamErr = '{% blocktrans with min_ram=min_ram %}Please enter a value in range {{min_ram}} - 200.{% endblocktrans %}';
</script> </script>

View file

@ -266,8 +266,8 @@ $( document ).ready(function() {
} }
var total = (cardPricing['cpu'].value * window.coresUnitPrice) + var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
(cardPricing['ram'].value * window.ramUnitPrice) + (cardPricing['ram'].value * window.ramUnitPrice) +
(cardPricing['storage'].value * window.ssdUnitPrice) - (cardPricing['storage'].value * window.ssdUnitPrice) +
window.discountAmount; window.vmBasePrice - window.discountAmount;
total = parseFloat(total.toFixed(2)); total = parseFloat(total.toFixed(2));
$("#total").text(total); $("#total").text(total);
} }