From 76efc35324b61c563c2de1e69834b6ccbe4ea99b Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 22 Sep 2018 06:44:37 +0200 Subject: [PATCH] Add enable_512mb_ram option in model/plugin --- datacenterlight/cms_models.py | 1 + datacenterlight/cms_plugins.py | 2 ++ datacenterlight/static/datacenterlight/js/main.js | 6 +++++- .../datacenterlight/includes/_calculator_form.html | 6 ++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 62a7b312..407ff6de 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -350,3 +350,4 @@ class DCLCalculatorPluginModel(CMSPlugin): "in the backend to be automatically listed in this " "calculator instance." ) + enable_512mb_ram = models.BooleanField(default=False) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 95a496d8..98b144b4 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -97,6 +97,8 @@ class DCLCalculatorPlugin(CMSPluginBase): context['templates'] = VMTemplate.objects.filter( vm_type=instance.vm_type ) + if instance.enable_512mb_ram: + context['enable_512mb_ram'] = True return context diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js index 292e8c16..679d38ea 100644 --- a/datacenterlight/static/datacenterlight/js/main.js +++ b/datacenterlight/static/datacenterlight/js/main.js @@ -5,6 +5,10 @@ /* --------------------------------------------- Scripts initialization --------------------------------------------- */ + var minRam = 1; + if(window.enable_512mb){ + minRam = 0.5; + } var cardPricing = { 'cpu': { 'id': 'coreValue', @@ -16,7 +20,7 @@ 'ram': { 'id': 'ramValue', 'value': 2, - 'min': 1, + 'min': minRam, 'max': 200, 'interval': 1 }, diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index 72ca5a05..bc4299ed 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -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.enable_512mb = {{vm_pricing.enable_512mb|default:false}}; {% endif %} @@ -54,8 +55,9 @@
- + {% firstof if enable_512mb_ram "0.5" endif "1" as myvar %} + GB RAM