From 28de423a1475f1fc4f167311be292a4ab41d34eb Mon Sep 17 00:00:00 2001
From: PCoder
Date: Fri, 6 Apr 2018 00:51:44 +0200
Subject: [PATCH 01/74] Add VMPricing model
---
datacenterlight/models.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index 6fcf24a9..01ddfdcf 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -12,6 +12,19 @@ class VMTemplate(models.Model):
return vm_template
+class VMPricing(models.Model):
+ name = models.CharField(max_length=255, unique=True)
+ vat_inclusive = models.BooleanField(default=True)
+ vat_percentage = models.DecimalField(decimal_places=2, blank=True)
+ cores_unit_price = models.DecimalField(decimal_places=2, default=0)
+ ram_unit_price = models.DecimalField(decimal_places=2, default= 0)
+ ssd_unit_price = models.DecimalField(decimal_places=2, default=0)
+ hdd_unit_price = models.DecimalField(decimal_places=2, default=0)
+
+ def __str__(self):
+ return self.name
+
+
class StripePlan(models.Model):
"""
A model to store Data Center Light's created Stripe plans
From d07cc41d0a102dd65938185331e3662fc9059cc4 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:17:48 +0200
Subject: [PATCH 02/74] Update VMPricing and add get_default_pricing class
method
---
datacenterlight/models.py | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index 01ddfdcf..3a376747 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -15,14 +15,33 @@ class VMTemplate(models.Model):
class VMPricing(models.Model):
name = models.CharField(max_length=255, unique=True)
vat_inclusive = models.BooleanField(default=True)
- vat_percentage = models.DecimalField(decimal_places=2, blank=True)
- cores_unit_price = models.DecimalField(decimal_places=2, default=0)
- ram_unit_price = models.DecimalField(decimal_places=2, default= 0)
- ssd_unit_price = models.DecimalField(decimal_places=2, default=0)
- hdd_unit_price = models.DecimalField(decimal_places=2, default=0)
+ vat_percentage = models.DecimalField(
+ max_digits=7, decimal_places=2, blank=True, default=0
+ )
+ cores_unit_price = models.DecimalField(
+ max_digits=7, decimal_places=2, default=0
+ )
+ ram_unit_price = models.DecimalField(
+ max_digits=7, decimal_places=2, default=0
+ )
+ ssd_unit_price = models.DecimalField(
+ max_digits=7, decimal_places=2, default=0
+ )
+ hdd_unit_price = models.DecimalField(
+ max_digits=7, decimal_places=2, default=0
+ )
def __str__(self):
- return self.name
+ return self.name + '-' + 'VAT' if self.vat_inclusive else 'NO_VAT'
+
+ @classmethod
+ def get_default_pricing(cls):
+ """ Returns the default pricing or None """
+ try:
+ default_pricing = VMPricing.objects.get(name='default')
+ except:
+ default_pricing = None
+ return default_pricing
class StripePlan(models.Model):
From c7afbb32c0d8f5d237bd96e480be30a5e64077bd Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:18:18 +0200
Subject: [PATCH 03/74] Add DCLCalculatorPluginModel
---
datacenterlight/cms_models.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py
index 9eb55e0c..583ac6a5 100644
--- a/datacenterlight/cms_models.py
+++ b/datacenterlight/cms_models.py
@@ -6,6 +6,8 @@ from django.utils.safestring import mark_safe
from djangocms_text_ckeditor.fields import HTMLField
from filer.fields.image import FilerImageField
+from datacenterlight.models import VMPricing
+
class CMSIntegration(models.Model):
name = models.CharField(
@@ -275,3 +277,12 @@ class DCLSectionPromoPluginModel(CMSPlugin):
if self.background_image:
extra_classes += ' promo-with-bg'
return extra_classes
+
+
+class DCLCalculatorPluginModel(DCLSectionPluginModel):
+ pricing = models.ForeignKey(
+ VMPricing,
+ default=VMPricing.get_default_pricing(),
+ help_text='Choose a pricing that will be associated with this '
+ 'Calculator'
+ )
From dd30542f9f14737cf59186f06a7ef3f2fbdac245 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:18:50 +0200
Subject: [PATCH 04/74] Use DCLCalculatorPluginModel in DCLCalculatorPlugin
---
datacenterlight/cms_plugins.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index a1a3833d..26ee9162 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -6,7 +6,7 @@ from .cms_models import (
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
DCLSectionPluginModel, DCLNavbarPluginModel,
- DCLSectionPromoPluginModel
+ DCLSectionPromoPluginModel, DCLCalculatorPluginModel
)
from .models import VMTemplate
@@ -76,7 +76,7 @@ class DCLSectionPromoPlugin(CMSPluginBase):
class DCLCalculatorPlugin(CMSPluginBase):
module = "Datacenterlight"
name = "DCL Calculator Plugin"
- model = DCLSectionPluginModel
+ model = DCLCalculatorPluginModel
render_template = "datacenterlight/cms/calculator.html"
cache = False
allow_children = True
From 4d6fdf2de97d6ba35397a9b83e71f82a2ed4b8f5 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:32:53 +0200
Subject: [PATCH 05/74] Add DCLCalculatorPluginModel and VMPricing models
---
.../migrations/0019_auto_20180409_1923.py | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 datacenterlight/migrations/0019_auto_20180409_1923.py
diff --git a/datacenterlight/migrations/0019_auto_20180409_1923.py b/datacenterlight/migrations/0019_auto_20180409_1923.py
new file mode 100644
index 00000000..4766cb5e
--- /dev/null
+++ b/datacenterlight/migrations/0019_auto_20180409_1923.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2018-04-09 19:23
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('datacenterlight', '0018_auto_20180403_1930'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='DCLCalculatorPluginModel',
+ fields=[
+ ('dclsectionpluginmodel_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='datacenterlight.DCLSectionPluginModel')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ bases=('datacenterlight.dclsectionpluginmodel',),
+ ),
+ migrations.CreateModel(
+ name='VMPricing',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=255, unique=True)),
+ ('vat_inclusive', models.BooleanField(default=True)),
+ ('vat_percentage', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=7)),
+ ('cores_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
+ ('ram_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
+ ('ssd_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
+ ('hdd_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='dclcalculatorpluginmodel',
+ name='pricing',
+ field=models.ForeignKey(default=None, help_text='Choose a pricing that will be associated with this Calculator', on_delete=django.db.models.deletion.CASCADE, to='datacenterlight.VMPricing'),
+ ),
+ ]
From 76c9b20cc9534e603b6caa6df59607c5eda706bd Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:34:09 +0200
Subject: [PATCH 06/74] Add VMPricing init migration
---
.../migrations/0020_auto_20180409_1928.py | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 datacenterlight/migrations/0020_auto_20180409_1928.py
diff --git a/datacenterlight/migrations/0020_auto_20180409_1928.py b/datacenterlight/migrations/0020_auto_20180409_1928.py
new file mode 100644
index 00000000..9a659acc
--- /dev/null
+++ b/datacenterlight/migrations/0020_auto_20180409_1928.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2018-04-09 19:28
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+DEFAULT_VMPRICING_NAME='default'
+
+
+def create_default_pricing(apps, schema_editor):
+ """
+ Create default pricing
+ :param apps:
+ :param schema_editor:
+ :return:
+ """
+ VMPricing = apps.get_model('datacenterlight', 'VMPricing')
+ if not VMPricing.objects.count():
+ vm_pricing = VMPricing(
+ name=DEFAULT_VMPRICING_NAME,
+ vat_inclusive=True,
+ cores_unit_price=5,
+ ram_unit_price=2,
+ ssd_unit_price=0.6,
+ hdd_unit_price=0.1,
+ )
+ vm_pricing.save()
+
+
+def undo_vm_pricing(apps, schema_editor):
+ """Deleting all entries for this model"""
+
+ VMPricing = apps.get_model("datacenterlight", "VMPricing")
+ VMPricing.objects.all().delete()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('datacenterlight', '0019_auto_20180409_1923'),
+ ]
+
+ operations = [
+ migrations.RunPython(
+ create_default_pricing,
+ reverse_code=undo_vm_pricing
+ ),
+ ]
From 1116812a994291c35493e12036db0fefb217289d Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 9 Apr 2018 21:40:03 +0200
Subject: [PATCH 07/74] Correct hdd price in VMPricing init
---
datacenterlight/migrations/0020_auto_20180409_1928.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/migrations/0020_auto_20180409_1928.py b/datacenterlight/migrations/0020_auto_20180409_1928.py
index 9a659acc..cea83a4c 100644
--- a/datacenterlight/migrations/0020_auto_20180409_1928.py
+++ b/datacenterlight/migrations/0020_auto_20180409_1928.py
@@ -22,7 +22,7 @@ def create_default_pricing(apps, schema_editor):
cores_unit_price=5,
ram_unit_price=2,
ssd_unit_price=0.6,
- hdd_unit_price=0.1,
+ hdd_unit_price=0.01,
)
vm_pricing.save()
From ebba6d3795076c4e06ac6fc66079013cd2bd16dc Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Thu, 12 Apr 2018 08:56:24 +0530
Subject: [PATCH 08/74] cms page extension favicon
---
datacenterlight/admin.py | 8 ++++-
datacenterlight/cms_models.py | 11 ++++++-
datacenterlight/cms_toolbar.py | 24 +++++++++++++++
.../migrations/0019_cmsfaviconextension.py | 29 +++++++++++++++++++
.../templates/datacenterlight/cms/base.html | 12 +++++---
5 files changed, 78 insertions(+), 6 deletions(-)
create mode 100644 datacenterlight/cms_toolbar.py
create mode 100644 datacenterlight/migrations/0019_cmsfaviconextension.py
diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py
index acb93fff..b8dc2f32 100644
--- a/datacenterlight/admin.py
+++ b/datacenterlight/admin.py
@@ -1,10 +1,16 @@
from django.contrib import admin
from cms.admin.placeholderadmin import PlaceholderAdminMixin
-from .cms_models import CMSIntegration
+from cms.extensions import PageExtensionAdmin
+from .cms_models import CMSIntegration, CMSFaviconExtension
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
list_display = ('name', 'domain')
+class CMSFaviconExtensionAdmin(PageExtensionAdmin):
+ pass
+
+
admin.site.register(CMSIntegration, CMSIntegrationAdmin)
+admin.site.register(CMSFaviconExtension, CMSFaviconExtensionAdmin)
diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py
index 9eb55e0c..4aec69b1 100644
--- a/datacenterlight/cms_models.py
+++ b/datacenterlight/cms_models.py
@@ -1,9 +1,12 @@
+from cms.extensions import PageExtension
+from cms.extensions.extension_pool import extension_pool
from cms.models.fields import PlaceholderField
from cms.models.pluginmodel import CMSPlugin
from django.contrib.sites.models import Site
from django.db import models
from django.utils.safestring import mark_safe
from djangocms_text_ckeditor.fields import HTMLField
+from filer.fields.file import FilerFileField
from filer.fields.image import FilerImageField
@@ -30,9 +33,15 @@ class CMSIntegration(models.Model):
return self.name
-# Models for CMS Plugins
+class CMSFaviconExtension(PageExtension):
+ favicon = FilerFileField(related_name="cms_favicon_image")
+extension_pool.register(CMSFaviconExtension)
+
+
+# Models for CMS Plugins
+
class DCLSectionPluginModel(CMSPlugin):
heading = models.CharField(
blank=True, null=True, max_length=100,
diff --git a/datacenterlight/cms_toolbar.py b/datacenterlight/cms_toolbar.py
new file mode 100644
index 00000000..15a8cb4b
--- /dev/null
+++ b/datacenterlight/cms_toolbar.py
@@ -0,0 +1,24 @@
+from cms.extensions.toolbar import ExtensionToolbar
+from cms.toolbar_pool import toolbar_pool
+from django.utils.translation import ugettext_lazy as _
+
+from .cms_models import CMSFaviconExtension
+
+
+@toolbar_pool.register
+class CMSFaviconExtensionToolbar(ExtensionToolbar):
+ # defineds the model for the current toolbar
+ model = CMSFaviconExtension
+
+ def populate(self):
+ # setup the extension toolbar with permissions and sanity checks
+ current_page_menu = self._setup_extension_toolbar()
+ # if it's all ok
+ if current_page_menu:
+ # retrieves the instance of the current extension (if any) and the toolbar item url
+ page_extension, url = self.get_page_extension_admin()
+ if url:
+ # adds a toolbar item
+ current_page_menu.add_modal_item(
+ _('CMS Favicon'), url=url, disabled=not self.toolbar.edit_mode
+ )
diff --git a/datacenterlight/migrations/0019_cmsfaviconextension.py b/datacenterlight/migrations/0019_cmsfaviconextension.py
new file mode 100644
index 00000000..7b350a70
--- /dev/null
+++ b/datacenterlight/migrations/0019_cmsfaviconextension.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2018-04-12 03:16
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import filer.fields.file
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('datacenterlight', '0018_auto_20180403_1930'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CMSFaviconExtension',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('extended_object', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='cms.Page')),
+ ('favicon', filer.fields.file.FilerFileField(on_delete=django.db.models.deletion.CASCADE, related_name='cms_favicon_image', to='filer.File')),
+ ('public_extension', models.OneToOneField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='draft_extension', to='datacenterlight.CMSFaviconExtension')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ ]
diff --git a/datacenterlight/templates/datacenterlight/cms/base.html b/datacenterlight/templates/datacenterlight/cms/base.html
index 0c356735..942a0ad4 100644
--- a/datacenterlight/templates/datacenterlight/cms/base.html
+++ b/datacenterlight/templates/datacenterlight/cms/base.html
@@ -8,9 +8,9 @@
-
+
- {% page_attribute page_title %}
+ {% page_attribute "page_title" %}
@@ -30,7 +30,11 @@
-
+ {% if request.current_page.cmsfaviconextension %}
+
+ {% else %}
+
+ {% endif %}
@@ -52,7 +56,7 @@
{% placeholder 'Datacenterlight Header' or %}
{% endplaceholder %}
From 588f513f2a1330a30829d3cb9f575f1acd814a39 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Thu, 12 Apr 2018 07:59:04 +0200
Subject: [PATCH 09/74] Remove initial VMPricing code from migration
---
...409_1923.py => 0019_auto_20180410_1948.py} | 2 +-
.../migrations/0020_auto_20180409_1928.py | 48 -------------------
2 files changed, 1 insertion(+), 49 deletions(-)
rename datacenterlight/migrations/{0019_auto_20180409_1923.py => 0019_auto_20180410_1948.py} (97%)
delete mode 100644 datacenterlight/migrations/0020_auto_20180409_1928.py
diff --git a/datacenterlight/migrations/0019_auto_20180409_1923.py b/datacenterlight/migrations/0019_auto_20180410_1948.py
similarity index 97%
rename from datacenterlight/migrations/0019_auto_20180409_1923.py
rename to datacenterlight/migrations/0019_auto_20180410_1948.py
index 4766cb5e..64a13128 100644
--- a/datacenterlight/migrations/0019_auto_20180409_1923.py
+++ b/datacenterlight/migrations/0019_auto_20180410_1948.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Generated by Django 1.9.4 on 2018-04-09 19:23
+# Generated by Django 1.9.4 on 2018-04-10 19:48
from __future__ import unicode_literals
from django.db import migrations, models
diff --git a/datacenterlight/migrations/0020_auto_20180409_1928.py b/datacenterlight/migrations/0020_auto_20180409_1928.py
deleted file mode 100644
index cea83a4c..00000000
--- a/datacenterlight/migrations/0020_auto_20180409_1928.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.9.4 on 2018-04-09 19:28
-from __future__ import unicode_literals
-
-from django.db import migrations
-
-DEFAULT_VMPRICING_NAME='default'
-
-
-def create_default_pricing(apps, schema_editor):
- """
- Create default pricing
- :param apps:
- :param schema_editor:
- :return:
- """
- VMPricing = apps.get_model('datacenterlight', 'VMPricing')
- if not VMPricing.objects.count():
- vm_pricing = VMPricing(
- name=DEFAULT_VMPRICING_NAME,
- vat_inclusive=True,
- cores_unit_price=5,
- ram_unit_price=2,
- ssd_unit_price=0.6,
- hdd_unit_price=0.01,
- )
- vm_pricing.save()
-
-
-def undo_vm_pricing(apps, schema_editor):
- """Deleting all entries for this model"""
-
- VMPricing = apps.get_model("datacenterlight", "VMPricing")
- VMPricing.objects.all().delete()
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('datacenterlight', '0019_auto_20180409_1923'),
- ]
-
- operations = [
- migrations.RunPython(
- create_default_pricing,
- reverse_code=undo_vm_pricing
- ),
- ]
From d50f282057a1a73c0ad81c1ae2ab388e69697e24 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Thu, 12 Apr 2018 08:01:43 +0200
Subject: [PATCH 10/74] Add create_vm_pricing management command
---
.../commands/create_default_vm_pricing.py | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 datacenterlight/management/commands/create_default_vm_pricing.py
diff --git a/datacenterlight/management/commands/create_default_vm_pricing.py b/datacenterlight/management/commands/create_default_vm_pricing.py
new file mode 100644
index 00000000..c1b36eea
--- /dev/null
+++ b/datacenterlight/management/commands/create_default_vm_pricing.py
@@ -0,0 +1,36 @@
+from django.core.management.base import BaseCommand
+
+from datacenterlight.models import VMPricing
+
+
+class Command(BaseCommand):
+ help = '''Creates default VMPricing object'''
+ DEFAULT_VMPRICING_NAME = 'default'
+
+ def handle(self, *args, **options):
+ self.create_default_vm_pricing()
+
+ def create_default_vm_pricing(self):
+ obj, created = VMPricing.objects.get_or_create(
+ name=self.DEFAULT_VMPRICING_NAME,
+ defaults={
+ "vat_inclusive": True,
+ "cores_unit_price": 5,
+ "ram_unit_price": 2,
+ "ssd_unit_price": 0.6,
+ "hdd_unit_price": 0.01
+ }
+ )
+
+ if created:
+ print(
+ 'Successfully created {} VMPricing object'.format(
+ self.DEFAULT_VMPRICING_NAME
+ )
+ )
+ else:
+ print(
+ '{} VMPricing exists already.'.format(
+ self.DEFAULT_VMPRICING_NAME
+ )
+ )
From 3e1d5ba0e20e37c80a1dc66f7de42354cc3fd404 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Thu, 12 Apr 2018 08:03:12 +0200
Subject: [PATCH 11/74] Improve string representation of VMPricing object
---
datacenterlight/models.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index 3a376747..a67d108c 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -1,5 +1,9 @@
+import logging
+
from django.db import models
+logger = logging.getLogger(__name__)
+
class VMTemplate(models.Model):
name = models.CharField(max_length=50)
@@ -32,14 +36,22 @@ class VMPricing(models.Model):
)
def __str__(self):
- return self.name + '-' + 'VAT' if self.vat_inclusive else 'NO_VAT'
+ return self.name + '-' + ' - '.join([
+ '{}/Core'.format(self.cores_unit_price),
+ '{}/GB RAM'.format(self.ram_unit_price),
+ '{}/GB SSD'.format(self.ssd_unit_price),
+ '{}/GB HDD'.format(self.hdd_unit_price),
+ '{}% VAT'.format(self.vat_percentage)
+ if not self.vat_inclusive else 'NO_VAT', ]
+ )
@classmethod
def get_default_pricing(cls):
""" Returns the default pricing or None """
try:
default_pricing = VMPricing.objects.get(name='default')
- except:
+ except Exception as e:
+ logger.error(str(e))
default_pricing = None
return default_pricing
From 0ea9051de119fc937150e840110401bec5f532b0 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Thu, 12 Apr 2018 08:38:10 +0200
Subject: [PATCH 12/74] Change the name of the DCL Calculator Plugin
DCL Caclulator Plugin -> DCL Calculator Section Plugin
Note: We do not change the plugin name itself because it causes
data loss
---
datacenterlight/cms_plugins.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index 26ee9162..fbc32b00 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -75,8 +75,8 @@ class DCLSectionPromoPlugin(CMSPluginBase):
@plugin_pool.register_plugin
class DCLCalculatorPlugin(CMSPluginBase):
module = "Datacenterlight"
- name = "DCL Calculator Plugin"
- model = DCLCalculatorPluginModel
+ name = "DCL Calculator Section Plugin"
+ model = DCLSectionPluginModel
render_template = "datacenterlight/cms/calculator.html"
cache = False
allow_children = True
From 56792893299cb24b965a67496a879197b9885704 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Thu, 12 Apr 2018 22:24:50 +0530
Subject: [PATCH 13/74] replaced cms_menu with static menu
---
.../blog.ungleich.ch/css/clean-blog.css | 2 +-
dynamicweb/urls.py | 33 +++++++----------
ungleich/templates/cms/ungleichch/_menu.html | 35 +++++++++++--------
3 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/digitalglarus/static/blog.ungleich.ch/css/clean-blog.css b/digitalglarus/static/blog.ungleich.ch/css/clean-blog.css
index 3c8f4e29..66e4c54d 100755
--- a/digitalglarus/static/blog.ungleich.ch/css/clean-blog.css
+++ b/digitalglarus/static/blog.ungleich.ch/css/clean-blog.css
@@ -70,7 +70,7 @@ hr.small {
}
.navbar-custom .navbar-brand {
color: white;
- padding: 20px;
+ padding: 5px 20px;
}
.navbar-custom .navbar-brand:hover,
.navbar-custom .navbar-brand:focus {
diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py
index ec43d1a5..c3d15c04 100644
--- a/dynamicweb/urls.py
+++ b/dynamicweb/urls.py
@@ -18,8 +18,8 @@ import debug_toolbar
urlpatterns = [
url(r'^index.html$', LandingView.as_view()),
- url(r'^open_api/', include('opennebula_api.urls',
- namespace='opennebula_api')),
+ url(r'^open_api/',
+ include('opennebula_api.urls', namespace='opennebula_api')),
url(r'^railshosting/', RailsHostingView.as_view(),
name="rails.hosting"),
url(r'^nodehosting/', NodeJSHostingView.as_view(),
@@ -28,8 +28,7 @@ urlpatterns = [
name="django.hosting"),
url(r'^nosystemd/', include('nosystemd.urls', namespace="nosystemd")),
url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')),
- url(r'^jsi18n/(?P\S+?)/$',
- i18n.javascript_catalog),
+ url(r'^jsi18n/(?P\S+?)/$', i18n.javascript_catalog),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += i18n_patterns(
@@ -45,28 +44,22 @@ urlpatterns += i18n_patterns(
url(r'^admin/', include(admin.site.urls)),
url(r'^datacenterlight/',
include('datacenterlight.urls', namespace="datacenterlight")),
- url(r'^hosting/', RedirectView.as_view(
- url=reverse_lazy('hosting:login')), name='redirect_hosting_login'),
+ url(r'^hosting/', RedirectView.as_view(url=reverse_lazy('hosting:login')),
+ name='redirect_hosting_login'),
url(r'^alplora/', include('alplora.urls', namespace="alplora")),
url(r'^membership/', include(membership_urls)),
- url(r'^digitalglarus/', include('digitalglarus.urls',
- namespace="digitalglarus")),
- url(r'^cms/blog/',
- include('ungleich.urls', namespace='ungleich')),
- url(
- r'^blog/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$',
+ url(r'^digitalglarus/',
+ include('digitalglarus.urls', namespace="digitalglarus")),
+ url(r'^cms/blog/', include('ungleich.urls', namespace='ungleich')),
+ url(r'^blog/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$',
RedirectView.as_view(pattern_name='ungleich:post-detail')),
- url(r'^blog/$', RedirectView.as_view(
- url=reverse_lazy('ungleich:post-list')
- ), name='blog_list_view'
- ),
+ url(r'^blog/$',
+ RedirectView.as_view(url=reverse_lazy('ungleich:post-list')), name='blog_list_view'),
url(r'^cms/', include('cms.urls')),
+ url(r'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')),
url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS
else LandingView.as_view()),
- url(r'^',
- include('ungleich_page.urls',
- namespace='ungleich_page'),
- name='ungleich_page'),
+ url(r'^', include('ungleich_page.urls', namespace='ungleich_page')),
)
urlpatterns += [
diff --git a/ungleich/templates/cms/ungleichch/_menu.html b/ungleich/templates/cms/ungleichch/_menu.html
index e17e90d6..6ccb043b 100644
--- a/ungleich/templates/cms/ungleichch/_menu.html
+++ b/ungleich/templates/cms/ungleichch/_menu.html
@@ -5,29 +5,34 @@
- {% for child in children %}
-
- {{ child.get_menu_title }}
- {% if child.children %}
-
- {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
-
- {% endif %}
-
- {% endfor %}
+
+ Ungleich Blog
+
+ {% comment %}
+ {% for child in children %}
+
+ {{ child.get_menu_title }}
+ {% if child.children %}
+
+ {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
+
+ {% endif %}
+
+ {% endfor %}
+ {% endcomment %}
From 2536f9405863b7e44cbf3d3fa035d7a1dbb42ac8 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Fri, 13 Apr 2018 17:44:00 +0530
Subject: [PATCH 14/74] django parler config fix
---
dynamicweb/settings/base.py | 2 +-
ungleich_page/static/ungleich_page/css/agency.css | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py
index 5db5a498..58c6b8e2 100644
--- a/dynamicweb/settings/base.py
+++ b/dynamicweb/settings/base.py
@@ -516,7 +516,7 @@ META_INCLUDE_KEYWORDS = ["ungleich", "hosting", "switzerland",
"Schweiz", "Swiss", "cdist"]
META_USE_SITES = True
-PARLER_LANGUAGES = {1: ({'code': 'en-us'}, {'code': 'de'},)}
+PARLER_LANGUAGES = {SITE_ID: ({'code': 'en-us'}, {'code': 'de'},)}
AUTH_USER_MODEL = 'membership.CustomUser'
# PAYMENT
diff --git a/ungleich_page/static/ungleich_page/css/agency.css b/ungleich_page/static/ungleich_page/css/agency.css
index 2b40158a..a4d2f4d3 100755
--- a/ungleich_page/static/ungleich_page/css/agency.css
+++ b/ungleich_page/static/ungleich_page/css/agency.css
@@ -235,13 +235,14 @@ fieldset[disabled] .btn-xl.active {
.navbar-default .navbar-nav>.active>a {
border-radius: 0;
color: #fff;
- background-color: #fed136;
+ background-color: transparent;
+ border-bottom: 2px solid #fed136;
}
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #fff;
- background-color: #fec503;
+ background-color: transparent;
}
.navbar-default .navbar-brand {
@@ -266,8 +267,8 @@ fieldset[disabled] .btn-xl.active {
}
.navbar-default .navbar-nav>.active>a {
- border-radius: 3px;
- }
+ /* border-radius: 3px; */
+ }
.navbar-default.navbar-shrink {
padding: 10px 0;
From 5b8b40f9673b22bc7ad2beacb1819b0d90114f3d Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Fri, 13 Apr 2018 17:49:27 +0530
Subject: [PATCH 15/74] restore ungleich style
---
ungleich_page/static/ungleich_page/css/agency.css | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/ungleich_page/static/ungleich_page/css/agency.css b/ungleich_page/static/ungleich_page/css/agency.css
index a4d2f4d3..2b40158a 100755
--- a/ungleich_page/static/ungleich_page/css/agency.css
+++ b/ungleich_page/static/ungleich_page/css/agency.css
@@ -235,14 +235,13 @@ fieldset[disabled] .btn-xl.active {
.navbar-default .navbar-nav>.active>a {
border-radius: 0;
color: #fff;
- background-color: transparent;
- border-bottom: 2px solid #fed136;
+ background-color: #fed136;
}
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #fff;
- background-color: transparent;
+ background-color: #fec503;
}
.navbar-default .navbar-brand {
@@ -267,8 +266,8 @@ fieldset[disabled] .btn-xl.active {
}
.navbar-default .navbar-nav>.active>a {
- /* border-radius: 3px; */
- }
+ border-radius: 3px;
+ }
.navbar-default.navbar-shrink {
padding: 10px 0;
From 283a0d25d183366ce3465891c693c58da1562a6a Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 13:31:55 +0200
Subject: [PATCH 16/74] Update get_vm_price method to use pricing defined in
VMPricing
---
utils/hosting_utils.py | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py
index 3c193ad7..d8c49b53 100644
--- a/utils/hosting_utils.py
+++ b/utils/hosting_utils.py
@@ -1,6 +1,7 @@
import logging
from oca.pool import WrongIdError
+from datacenterlight.models import VMPricing
from hosting.models import UserHostingKey, VMDetail
from opennebula_api.serializers import VirtualMachineSerializer
@@ -49,14 +50,29 @@ def get_or_create_vm_detail(user, manager, vm_id):
return vm_detail_obj
-def get_vm_price(cpu, memory, disk_size):
+def get_vm_price(cpu, memory, disk_size, hdd_size=0, pricing_name='default'):
"""
A helper function that computes price of a VM from given cpu, ram and
ssd parameters
:param cpu: Number of cores of the VM
:param memory: RAM of the VM
- :param disk_size: Disk space of the VM
+ :param disk_size: Disk space of the VM (SSD)
+ :param hdd_size: The HDD size
+ :param pricing_name: The pricing name to be used
:return: The price of the VM
"""
- return (cpu * 5) + (memory * 2) + (disk_size * 0.6)
+ try:
+ pricing = VMPricing.objects.get(name=pricing_name)
+ except Exception as ex:
+ logger.error(
+ "Error getting VMPricing object for {pricing_name}."
+ "Details: {details}".format(
+ pricing_name=pricing_name, details=str(ex)
+ )
+ )
+ return None
+ return ((cpu * pricing.cores_unit_price) +
+ (memory * pricing.ram_unit_price) +
+ (disk_size * pricing.sdd_unit_price) +
+ (hdd_size * pricing.hdd_unit_price))
From 74393ac6ace4ab766e5a0abc43a423237a42a2b8 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 13:32:53 +0200
Subject: [PATCH 17/74] Optimize imports
---
datacenterlight/cms_plugins.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index fbc32b00..9e3376eb 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -6,7 +6,7 @@ from .cms_models import (
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
DCLSectionPluginModel, DCLNavbarPluginModel,
- DCLSectionPromoPluginModel, DCLCalculatorPluginModel
+ DCLSectionPromoPluginModel
)
from .models import VMTemplate
From 82a2014fa5b7b458b675045f5b0024c57e562d59 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 13:34:55 +0200
Subject: [PATCH 18/74] Pass vm_pricing context from default VMPricing object
---
datacenterlight/cms_plugins.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index 9e3376eb..9bb87bd8 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -8,7 +8,7 @@ from .cms_models import (
DCLSectionPluginModel, DCLNavbarPluginModel,
DCLSectionPromoPluginModel
)
-from .models import VMTemplate
+from .models import VMTemplate, VMPricing
@plugin_pool.register_plugin
@@ -91,6 +91,8 @@ class DCLCalculatorPlugin(CMSPluginBase):
context['templates'] = VMTemplate.objects.all()
context['children_to_side'] = []
context['children_to_content'] = []
+ context['vm_pricing'] = VMPricing.get_default_pricing()
+
if instance.child_plugin_instances is not None:
context['children_to_content'].extend(
instance.child_plugin_instances
From aa55c1e868bdc5df1cb7f0956213c0b82cda30a8 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 13:37:06 +0200
Subject: [PATCH 19/74] Update main.js to compute total from the unitprice's
defined in the window context
---
datacenterlight/static/datacenterlight/js/main.js | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js
index 6753695c..35f2b247 100644
--- a/datacenterlight/static/datacenterlight/js/main.js
+++ b/datacenterlight/static/datacenterlight/js/main.js
@@ -171,7 +171,18 @@
}
function _calcPricing() {
- var total = (cardPricing['cpu'].value * 5) + (2 * cardPricing['ram'].value) + (0.6 * cardPricing['storage'].value);
+ if(typeof window.coresUnitPrice === 'undefined'){
+ window.coresUnitPrice = 5;
+ }
+ if(typeof window.ramUnitPrice === 'undefined'){
+ window.coresUnitPrice = 2;
+ }
+ if(typeof window.ssdUnitPrice === 'undefined'){
+ window.ssdUnitPrice = 0.6;
+ }
+ var total = (cardPricing['cpu'].value * window.coresUnitPrice) +
+ (cardPricing['ram'].value * window.ramUnitPrice) +
+ (cardPricing['storage'].value * window.ssdUnitPrice);
total = parseFloat(total.toFixed(2));
$("#total").text(total);
}
From c738888ab2dcb118816607938eff3c61583e4c4f Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 13:39:01 +0200
Subject: [PATCH 20/74] Set vm unit price parameters from the passed context
---
.../datacenterlight/includes/_calculator_form.html | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
index f38150bb..05201b11 100644
--- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
+++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
@@ -1,4 +1,14 @@
{% load staticfiles i18n%}
+{% if vm_pricing %}
+
+{% endif %}
+ {% if vm.vat > 0 %}
+
+ {% trans "VAT" %}:
+ {{vm.vat|floatformat|intcomma}} CHF
+
+ {% endif %}
{% trans "Total" %}
- {{vm.price|intcomma}} CHF
+ {{vm.total_price|floatformat|intcomma}} CHF
@@ -78,7 +84,7 @@
{% csrf_token %}
-
{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price }}CHF/month{% endblocktrans %}.
+
{% blocktrans with vm_total_price=vm.total_price|floatformat|intcomma %}By clicking "Place order" this plan will charge your credit card account with the fee of {{vm_total_price}} CHF/month{% endblocktrans %}.
From d296ce72cbdc7be902f3504b325383d0ff0a9d86 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 21:37:51 +0200
Subject: [PATCH 28/74] Register VMPricing with admin site
---
datacenterlight/admin.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py
index acb93fff..3e5927e8 100644
--- a/datacenterlight/admin.py
+++ b/datacenterlight/admin.py
@@ -1,10 +1,11 @@
from django.contrib import admin
from cms.admin.placeholderadmin import PlaceholderAdminMixin
from .cms_models import CMSIntegration
+from .models import VMPricing
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
list_display = ('name', 'domain')
-
admin.site.register(CMSIntegration, CMSIntegrationAdmin)
+admin.site.register(VMPricing)
From 069ba34f94f7be299769a0635797b944e6b7a5d9 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:07:07 +0200
Subject: [PATCH 29/74] Remove old migration file
---
.../migrations/0019_auto_20180410_1948.py | 44 -------------------
1 file changed, 44 deletions(-)
delete mode 100644 datacenterlight/migrations/0019_auto_20180410_1948.py
diff --git a/datacenterlight/migrations/0019_auto_20180410_1948.py b/datacenterlight/migrations/0019_auto_20180410_1948.py
deleted file mode 100644
index 64a13128..00000000
--- a/datacenterlight/migrations/0019_auto_20180410_1948.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.9.4 on 2018-04-10 19:48
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('datacenterlight', '0018_auto_20180403_1930'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='DCLCalculatorPluginModel',
- fields=[
- ('dclsectionpluginmodel_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='datacenterlight.DCLSectionPluginModel')),
- ],
- options={
- 'abstract': False,
- },
- bases=('datacenterlight.dclsectionpluginmodel',),
- ),
- migrations.CreateModel(
- name='VMPricing',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=255, unique=True)),
- ('vat_inclusive', models.BooleanField(default=True)),
- ('vat_percentage', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=7)),
- ('cores_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
- ('ram_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
- ('ssd_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
- ('hdd_unit_price', models.DecimalField(decimal_places=2, default=0, max_digits=7)),
- ],
- ),
- migrations.AddField(
- model_name='dclcalculatorpluginmodel',
- name='pricing',
- field=models.ForeignKey(default=None, help_text='Choose a pricing that will be associated with this Calculator', on_delete=django.db.models.deletion.CASCADE, to='datacenterlight.VMPricing'),
- ),
- ]
From 6575ff1afec424a5f39902715ed68585f11d31d5 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:07:50 +0200
Subject: [PATCH 30/74] Increase decimal_places for all VMPricing fields
---
datacenterlight/models.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index 86158394..5059e740 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -20,19 +20,19 @@ class VMPricing(models.Model):
name = models.CharField(max_length=255, unique=True)
vat_inclusive = models.BooleanField(default=True)
vat_percentage = models.DecimalField(
- max_digits=7, decimal_places=2, blank=True, default=0
+ max_digits=7, decimal_places=5, blank=True, default=0
)
cores_unit_price = models.DecimalField(
- max_digits=7, decimal_places=2, default=0
+ max_digits=7, decimal_places=5, default=0
)
ram_unit_price = models.DecimalField(
- max_digits=7, decimal_places=2, default=0
+ max_digits=7, decimal_places=5, default=0
)
ssd_unit_price = models.DecimalField(
- max_digits=7, decimal_places=2, default=0
+ max_digits=7, decimal_places=5, default=0
)
hdd_unit_price = models.DecimalField(
- max_digits=7, decimal_places=2, default=0
+ max_digits=7, decimal_places=6, default=0
)
def __str__(self):
From fc0bc52ea34c264bd27417e794a4da72df765098 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:18:22 +0200
Subject: [PATCH 31/74] Rename model
DCLCalculatorPluginModel -> DCLCustomPricingModelModel
---
datacenterlight/cms_models.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py
index 583ac6a5..64f21ddc 100644
--- a/datacenterlight/cms_models.py
+++ b/datacenterlight/cms_models.py
@@ -279,10 +279,10 @@ class DCLSectionPromoPluginModel(CMSPlugin):
return extra_classes
-class DCLCalculatorPluginModel(DCLSectionPluginModel):
+class DCLCustomPricingModel(CMSPlugin):
pricing = models.ForeignKey(
VMPricing,
- default=VMPricing.get_default_pricing(),
+ related_name="dcl_custom_pricing_vm_pricing",
help_text='Choose a pricing that will be associated with this '
'Calculator'
)
From 45fc0dbaac1ca1b0f9ce7833de9092f45c715bd2 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:23:42 +0200
Subject: [PATCH 32/74] Add .orig to .gitignore
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index e09fef54..1b2b4d16 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,5 @@ secret-key
/utils/optimize/
# to keep empty dirs
-!.gitkeep
\ No newline at end of file
+!.gitkeep
+*.orig
From 465431d858c2ed5c8df86e15e5097b4874905fcb Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:24:15 +0200
Subject: [PATCH 33/74] Add DCLCustomPricingPlugin
---
datacenterlight/cms_plugins.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index 9bb87bd8..d504956a 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -6,7 +6,7 @@ from .cms_models import (
DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel,
DCLSectionIconPluginModel, DCLSectionImagePluginModel,
DCLSectionPluginModel, DCLNavbarPluginModel,
- DCLSectionPromoPluginModel
+ DCLSectionPromoPluginModel, DCLCustomPricingModel
)
from .models import VMTemplate, VMPricing
@@ -81,7 +81,7 @@ class DCLCalculatorPlugin(CMSPluginBase):
cache = False
allow_children = True
child_classes = [
- 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin'
+ 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin', 'DCLCustomPricingPlugin'
]
def render(self, context, instance, placeholder):
@@ -100,6 +100,14 @@ class DCLCalculatorPlugin(CMSPluginBase):
return context
+@plugin_pool.register_plugin
+class DCLCustomPricingPlugin(CMSPluginBase):
+ module = "Datacenterlight"
+ name = "DCL Custom Pricing Plugin"
+ model = DCLCustomPricingModel
+ render_plugin = False
+
+
@plugin_pool.register_plugin
class DCLBannerListPlugin(CMSPluginBase):
module = "Datacenterlight"
From 665fa7479b7225a723e75b9ea1a02786de536287 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Sun, 15 Apr 2018 23:32:14 +0200
Subject: [PATCH 34/74] Add 0019_auto_20180415_2129.py
---
.../migrations/0019_auto_20180415_2129.py | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 datacenterlight/migrations/0019_auto_20180415_2129.py
diff --git a/datacenterlight/migrations/0019_auto_20180415_2129.py b/datacenterlight/migrations/0019_auto_20180415_2129.py
new file mode 100644
index 00000000..19809a4d
--- /dev/null
+++ b/datacenterlight/migrations/0019_auto_20180415_2129.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2018-04-15 21:29
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('cms', '0014_auto_20160404_1908'),
+ ('datacenterlight', '0018_auto_20180403_1930'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='DCLCustomPricingModel',
+ fields=[
+ ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ bases=('cms.cmsplugin',),
+ ),
+ migrations.CreateModel(
+ name='VMPricing',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=255, unique=True)),
+ ('vat_inclusive', models.BooleanField(default=True)),
+ ('vat_percentage', models.DecimalField(blank=True, decimal_places=5, default=0, max_digits=7)),
+ ('cores_unit_price', models.DecimalField(decimal_places=5, default=0, max_digits=7)),
+ ('ram_unit_price', models.DecimalField(decimal_places=5, default=0, max_digits=7)),
+ ('ssd_unit_price', models.DecimalField(decimal_places=5, default=0, max_digits=7)),
+ ('hdd_unit_price', models.DecimalField(decimal_places=6, default=0, max_digits=7)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='dclcustompricingmodel',
+ name='pricing',
+ field=models.ForeignKey(help_text='Choose a pricing that will be associated with this Calculator', on_delete=django.db.models.deletion.CASCADE, related_name='dcl_custom_pricing_vm_pricing', to='datacenterlight.VMPricing'),
+ ),
+ ]
From 896984ef1f0f8105760fdcba86e1d515d3757c2c Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 00:29:23 +0200
Subject: [PATCH 35/74] Set vm_pricing context from plugins value
---
datacenterlight/cms_plugins.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index d504956a..2ad07249 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -91,7 +91,21 @@ class DCLCalculatorPlugin(CMSPluginBase):
context['templates'] = VMTemplate.objects.all()
context['children_to_side'] = []
context['children_to_content'] = []
- context['vm_pricing'] = VMPricing.get_default_pricing()
+ pricing_plugin_model = None
+ for child in instance.child_plugin_instances:
+ if child.__class__.__name__ == 'DCLCustomPricingModel':
+ # The second clause is just to make sure we pick up the most
+ # recent CustomPricing, if more than one is present
+ if (pricing_plugin_model is None or child.pricing_id >
+ pricing_plugin_model.model.pricing_id):
+ pricing_plugin_model = child
+
+ if pricing_plugin_model:
+ context['vm_pricing'] = VMPricing.get_vm_pricing_by_name(
+ name=pricing_plugin_model.pricing.name
+ )
+ else:
+ context['vm_pricing'] = VMPricing.get_default_pricing()
if instance.child_plugin_instances is not None:
context['children_to_content'].extend(
From 1cb3fa80cf03bfa859b7ea766c1198d28112b83c Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 00:29:43 +0200
Subject: [PATCH 36/74] Improve logger error
---
datacenterlight/models.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index 5059e740..cddab497 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -52,7 +52,8 @@ class VMPricing(models.Model):
except Exception as e:
logger.error(
"Error getting VMPricing with name {name}. "
- "Details: {details}".format(name=name, details=str(e))
+ "Details: {details}. Attempting to return default"
+ "pricing.".format(name=name, details=str(e))
)
pricing = VMPricing.get_default_pricing()
return pricing
From 68032ec184b35bc2e2b7341f20744f9579ed24b5 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 00:49:55 +0200
Subject: [PATCH 37/74] Update migration file
---
.../{0019_auto_20180415_2129.py => 0019_auto_20180415_2236.py} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename datacenterlight/migrations/{0019_auto_20180415_2129.py => 0019_auto_20180415_2236.py} (97%)
diff --git a/datacenterlight/migrations/0019_auto_20180415_2129.py b/datacenterlight/migrations/0019_auto_20180415_2236.py
similarity index 97%
rename from datacenterlight/migrations/0019_auto_20180415_2129.py
rename to datacenterlight/migrations/0019_auto_20180415_2236.py
index 19809a4d..4b711a2b 100644
--- a/datacenterlight/migrations/0019_auto_20180415_2129.py
+++ b/datacenterlight/migrations/0019_auto_20180415_2236.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Generated by Django 1.9.4 on 2018-04-15 21:29
+# Generated by Django 1.9.4 on 2018-04-15 22:36
from __future__ import unicode_literals
from django.db import migrations, models
From ec753eb0d59887f16cd6d9b728dc86a3a5df147c Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 00:50:34 +0200
Subject: [PATCH 38/74] Improve string representation of VMPricing
---
datacenterlight/models.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/datacenterlight/models.py b/datacenterlight/models.py
index cddab497..eceb7617 100644
--- a/datacenterlight/models.py
+++ b/datacenterlight/models.py
@@ -36,13 +36,13 @@ class VMPricing(models.Model):
)
def __str__(self):
- return self.name + '-' + ' - '.join([
- '{}/Core'.format(self.cores_unit_price),
- '{}/GB RAM'.format(self.ram_unit_price),
- '{}/GB SSD'.format(self.ssd_unit_price),
- '{}/GB HDD'.format(self.hdd_unit_price),
- '{}% VAT'.format(self.vat_percentage)
- if not self.vat_inclusive else 'NO_VAT', ]
+ return self.name + ' => ' + ' - '.join([
+ '{}/Core'.format(self.cores_unit_price.normalize()),
+ '{}/GB RAM'.format(self.ram_unit_price.normalize()),
+ '{}/GB SSD'.format(self.ssd_unit_price.normalize()),
+ '{}/GB HDD'.format(self.hdd_unit_price.normalize()),
+ '{}% VAT'.format(self.vat_percentage.normalize())
+ if not self.vat_inclusive else 'VAT-Incl', ]
)
@classmethod
From 903336a46fc16541f7592c32e08ff554baacd195 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 00:59:42 +0200
Subject: [PATCH 39/74] Show 2 upto decimal places in order detail
---
datacenterlight/templates/datacenterlight/order_detail.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html
index 20ff4db3..f26bc450 100644
--- a/datacenterlight/templates/datacenterlight/order_detail.html
+++ b/datacenterlight/templates/datacenterlight/order_detail.html
@@ -68,12 +68,12 @@
{% if vm.vat > 0 %}
{% trans "VAT" %}:
- {{vm.vat|floatformat|intcomma}} CHF
+ {{vm.vat|floatformat:2|intcomma}} CHF
{% endif %}
{% trans "Total" %}
- {{vm.total_price|floatformat|intcomma}} CHF
+ {{vm.total_price|floatformat:2|intcomma}} CHF
@@ -84,7 +84,7 @@
{% csrf_token %}
-
{% blocktrans with vm_total_price=vm.total_price|floatformat|intcomma %}By clicking "Place order" this plan will charge your credit card account with the fee of {{vm_total_price}} CHF/month{% endblocktrans %}.
+
{% blocktrans with vm_total_price=vm.total_price|floatformat:2|intcomma %}By clicking "Place order" this plan will charge your credit card account with the fee of {{vm_total_price}} CHF/month{% endblocktrans %}.
From 6d6a8ea597aaed145d69a9360abf267744554d0b Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:24:21 +0200
Subject: [PATCH 40/74] Refactor: reuse final_price variable
---
datacenterlight/tasks.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py
index 3db6eb54..5ba6e066 100644
--- a/datacenterlight/tasks.py
+++ b/datacenterlight/tasks.py
@@ -130,7 +130,7 @@ def create_vm_task(self, vm_template_id, user, specs, template,
'cores': specs.get('cpu'),
'memory': specs.get('memory'),
'storage': specs.get('disk_size'),
- 'price': specs.get('price'),
+ 'price': final_price,
'template': template.get('name'),
'vm_name': vm.get('name'),
'vm_id': vm['vm_id'],
From 8e28756bd8f78328f8d7e32f786c715f715ac569 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:26:19 +0200
Subject: [PATCH 41/74] Check if we have total_price (indicates that we have
VAT excluded price);hence,use it as final_price. if not use the previous
casei and use it as final_price. If not use the preivous case
---
datacenterlight/tasks.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py
index 5ba6e066..869cf1f8 100644
--- a/datacenterlight/tasks.py
+++ b/datacenterlight/tasks.py
@@ -56,7 +56,8 @@ def create_vm_task(self, vm_template_id, user, specs, template,
"Running create_vm_task on {}".format(current_task.request.hostname))
vm_id = None
try:
- final_price = specs.get('price')
+ final_price = (specs.get('total_price') if 'total_price' in specs
+ else specs.get('price'))
billing_address = BillingAddress(
cardholder_name=billing_address_data['cardholder_name'],
street_address=billing_address_data['street_address'],
From 1b37eed53da0fcbf26e01f5c4c7f44e0075d849d Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:29:07 +0200
Subject: [PATCH 42/74] Include pricing_name in the email sent to admin
---
datacenterlight/tasks.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py
index 869cf1f8..df91387e 100644
--- a/datacenterlight/tasks.py
+++ b/datacenterlight/tasks.py
@@ -19,6 +19,8 @@ from utils.forms import UserBillingAddressForm
from utils.mailer import BaseEmail
from utils.models import BillingAddress
+from .models import VMPricing
+
logger = get_task_logger(__name__)
@@ -137,6 +139,10 @@ def create_vm_task(self, vm_template_id, user, specs, template,
'vm_id': vm['vm_id'],
'order_id': order.id
}
+ if 'pricing_name' in specs:
+ context['pricing'] = str(VMPricing.get_vm_pricing_by_name(
+ name=specs['pricing_name']
+ ))
email_data = {
'subject': settings.DCL_TEXT + " Order from %s" % context['email'],
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
From d0276f22c129f52d7a321b47cce84787ed81b41d Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:30:02 +0200
Subject: [PATCH 43/74] Reorganize imports
---
datacenterlight/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index e2d28245..7f498824 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -19,7 +19,7 @@ from hosting.models import HostingOrder
from membership.models import CustomUser, StripeCustomer
from opennebula_api.serializers import VMTemplateSerializer
from utils.forms import BillingAddressForm, BillingAddressFormSignup
-from utils.hosting_utils import get_vm_price, get_vm_price_with_vat
+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 .forms import ContactForm
From 4148eff03e756fb1ca36e6f55a744f1a0b06d20f Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:31:16 +0200
Subject: [PATCH 44/74] Rename variable: amount_to_be_charged -> price
---
datacenterlight/views.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index 7f498824..3710d41b 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -158,7 +158,7 @@ class IndexView(CreateView):
)
return HttpResponseRedirect(referer_url + "#order_form")
- amount_to_be_charged, vat = get_vm_price_with_vat(
+ price, vat = get_vm_price_with_vat(
cpu=cores,
memory=memory,
disk_size=storage,
@@ -168,9 +168,9 @@ class IndexView(CreateView):
'cpu': cores,
'memory': memory,
'disk_size': storage,
- 'price': amount_to_be_charged,
+ 'price': price,
'vat': vat,
- 'total_price': amount_to_be_charged + vat,
+ 'total_price': price + vat,
'pricing_name': vm_pricing_name
}
request.session['specs'] = specs
From 95daa3767053005a9a5afb964f8487f6c6b1d7fa Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:32:38 +0200
Subject: [PATCH 45/74] Use total_price for amout to be charged, always
---
datacenterlight/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index 3710d41b..e76ef31d 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -421,7 +421,7 @@ class OrderConfirmationView(DetailView):
cpu = specs.get('cpu')
memory = specs.get('memory')
disk_size = specs.get('disk_size')
- amount_to_be_charged = specs.get('price')
+ amount_to_be_charged = specs.get('total_price')
plan_name = StripeUtils.get_stripe_plan_name(cpu=cpu,
memory=memory,
disk_size=disk_size)
From c5029d875287f14b390496e48aa2268b8bf32e8e Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 01:47:55 +0200
Subject: [PATCH 46/74] Update datacenterlight's django.po
---
.../locale/de/LC_MESSAGES/django.po | 171 ++++++++++--------
1 file changed, 92 insertions(+), 79 deletions(-)
diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po
index 5942573b..3dc4650b 100644
--- a/datacenterlight/locale/de/LC_MESSAGES/django.po
+++ b/datacenterlight/locale/de/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-03-30 21:29+0000\n"
+"POT-Creation-Date: 2018-04-15 23:37+0000\n"
"PO-Revision-Date: 2018-03-30 23:22+0000\n"
"Last-Translator: b'Anonymous User '\n"
"Language-Team: LANGUAGE \n"
@@ -72,9 +72,9 @@ msgstr "Data Center Light Account Aktivierung"
#, python-format
msgid ""
-"You can activate your Data Center Light account by clicking here ."
+"You can activate your Data Center Light account by clicking here ."
msgstr ""
"Klicke hier um deinen Data Center "
@@ -101,8 +101,8 @@ msgid ""
"You can reset your password here ."
msgstr ""
-"Du kannst dein Passwort hier "
+"Du kannst dein Passwort hier "
"zurücksetzen."
msgid "Your Data Center Light Team"
@@ -160,21 +160,6 @@ msgstr "Weiter"
msgid "Home"
msgstr "Home"
-msgid "Highlights"
-msgstr ""
-
-msgid "Scale out"
-msgstr "Skalierung"
-
-msgid "Reliable and light"
-msgstr "Zuverlässig und leicht"
-
-msgid "Pricing"
-msgstr "Preise"
-
-msgid "Order VM"
-msgstr "VM bestellen"
-
msgid "Contact"
msgstr "Kontakt"
@@ -184,6 +169,9 @@ msgstr "Nutzungsbedingungen"
msgid "Finally, an affordable VM hosting in Switzerland!"
msgstr "Endlich: bezahlbares VM Hosting in der Schweiz"
+msgid "Highlights"
+msgstr ""
+
msgid "I want it!"
msgstr "Das will ich haben!"
@@ -203,8 +191,8 @@ msgid ""
"order to make it more sustainable and affordable at the same time."
msgstr ""
"Ist kreativ, indem es sich ein modernes und alternatives Layout zu Nutze "
-"macht um Nachhaltigkeit zu fördern und somit erschwingliche Preise bieten zu"
-" können.
"
+"macht um Nachhaltigkeit zu fördern und somit erschwingliche Preise bieten zu "
+"können.
"
msgid ""
"Cuts down the costs for you by using FOSS (Free Open Source Software) "
@@ -214,6 +202,9 @@ msgstr ""
"mit FOSS (Free Open Source Software) arbeitet und wir daher auf "
"Lizenzgebühren verzichten können.
"
+msgid "Scale out"
+msgstr "Skalierung"
+
msgid ""
"We don't use special hardware. We use commodity hardware: we buy computers "
"that you buy. Just many more and put them in a cozy home for computers "
@@ -223,6 +214,9 @@ msgstr ""
"erschwingliche Systeme. Bei grösserer Auslastung werden mehr "
"Standardkomponenten hinzugekauft und skalieren so das Datencenter."
+msgid "Reliable and light"
+msgstr "Zuverlässig und leicht"
+
msgid ""
"Our VMs are located in Switzerland, with reliable power supply and fast "
"internet connection. Our VM costs less thanks to our featherlight "
@@ -232,8 +226,7 @@ msgstr ""
"Energieversorgung, sowie schneller Internetverbindung ausgestattet. Unser "
"Angebot ist aufgrund unserer leichten Infrastruktur überaus kostengünstig."
-msgid ""
-"Simple and affordable: Try our virtual machine with featherlight price."
+msgid "Simple and affordable: Try our virtual machine with featherlight price."
msgstr ""
"Einfach und bezahlbar: Teste nun unsere virtuellen Maschinen mit "
"federleichten Preisen."
@@ -314,6 +307,9 @@ msgstr "Gesamt"
msgid "including VAT"
msgstr "inkl. Mehrwertsteuer"
+msgid "excluding VAT"
+msgstr "exkl. Mehrwertsteuer"
+
msgid "Month"
msgstr "Monat"
@@ -321,20 +317,20 @@ msgid "Credit Card"
msgstr "Kreditkarte"
msgid ""
-"Please fill in your credit card information below. We are using Stripe for payment and do "
-"not store your information in our database."
+"Please fill in your credit card information below. We are using Stripe for payment and do not "
+"store your information in our database."
msgstr ""
-"Bitte fülle Deine Kreditkarteninformationen unten aus. Wir nutzen Stripe für die Bezahlung "
-"und speichern keine Informationen in unserer Datenbank."
+"Bitte fülle Deine Kreditkarteninformationen unten aus. Wir nutzen Stripe für die Bezahlung und "
+"speichern keine Informationen in unserer Datenbank."
msgid ""
"You are not making any payment yet. After submitting your card information, "
"you will be taken to the Confirm Order Page."
msgstr ""
-"Es wird noch keine Bezahlung vorgenommen. Die Bezahlung wird erst ausgelöst,"
-" nachdem Du die Bestellung auf der nächsten Seite bestätigt hast."
+"Es wird noch keine Bezahlung vorgenommen. Die Bezahlung wird erst ausgelöst, "
+"nachdem Du die Bestellung auf der nächsten Seite bestätigt hast."
msgid "Card Number"
msgstr "Kreditkartennummer"
@@ -352,8 +348,8 @@ msgid ""
"You are not making any payment yet. After placing your order, you will be "
"taken to the Submit Payment Page."
msgstr ""
-"Es wird noch keine Bezahlung vorgenommen. Die Bezahlung wird erst ausgelöst,"
-" nachdem Du die Bestellung auf der nächsten Seite bestätigt hast."
+"Es wird noch keine Bezahlung vorgenommen. Die Bezahlung wird erst ausgelöst, "
+"nachdem Du die Bestellung auf der nächsten Seite bestätigt hast."
msgid "Processing"
msgstr "Weiter"
@@ -383,12 +379,14 @@ msgstr "Bestellungsübersicht"
msgid "Product"
msgstr "Produkt"
-#, python-format
+msgid "VAT"
+msgstr "Mehrwertsteuer"
+
msgid ""
"By clicking \"Place order\" this plan will charge your credit card account "
-"with the fee of %(vm_price)sCHF/month"
+"with the fee of %(vm_total_price)s CHF/month"
msgstr ""
-"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_price)sCHF "
+"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_total_price)s CHF "
"pro Monat belastet"
msgid "Place order"
@@ -455,25 +453,25 @@ msgstr "Wir unterstützen die FOSS Community."
msgid ""
"Data Center Light is the child of free and open source software (FOSS) "
"movement. We grew up with it, live by it, and believe in it. The "
-"more we work on our data center, the more we contribute back to the FOSS"
-" community."
+"more we work on our data center, the more we contribute back to the FOSS "
+"community."
msgstr ""
"Data Center Light ist ein Teil der Free und Opens Source Software (FOSS) "
-"Bewegung. Wir sind damit gross geworden, leben damit und glauben "
-"daran. Je weiter wir mit unserem Data Center Light vorankommen, desto "
-"mehr können wir etwas an die FOSS Community zurückgeben."
+"Bewegung. Wir sind damit gross geworden, leben damit und glauben daran."
+" Je weiter wir mit unserem Data Center Light vorankommen, desto mehr "
+"können wir etwas an die FOSS Community zurückgeben."
msgid "We bring the future to you."
msgstr "Wir bringen die Zukunft zu dir."
msgid ""
"Data Center Light uses the most modern technologies out there. Your VM "
-"needs only IPv6. Data Center Light provides transparent two-way "
-"IPv6/IPv4 translation."
+"needs only IPv6. Data Center Light provides transparent two-way IPv6/"
+"IPv4 translation."
msgstr ""
"Data Center Light verwendet die zur Zeit modernsten Technologien. Deine "
-"VM läuft mit IPv6. Data Center Light bietet eine transparente "
-"IPv6/IPv4-Zweiweglösung."
+"VM läuft mit IPv6. Data Center Light bietet eine transparente IPv6/IPv4-"
+"Zweiweglösung."
msgid ""
" No more spinning metal plates! Data Center Light uses only SSDs. We keep "
@@ -497,6 +495,10 @@ msgstr "Ungültige RAM-Grösse"
msgid "Invalid storage size"
msgstr "Ungültige Speicher-Grösse"
+#, python-brace-format
+msgid "Incorrect pricing name. Please contact support{support_email}"
+msgstr ""
+
msgid "Confirm Order"
msgstr "Bestellung Bestätigen"
@@ -507,8 +509,8 @@ msgid ""
"There was a payment related error. On close of this popup, you will be "
"redirected back to the payment page."
msgstr ""
-"Es ist ein Fehler bei der Zahlung betreten. Du wirst nach dem Schliessen vom"
-" Popup zur Bezahlseite weitergeleitet."
+"Es ist ein Fehler bei der Zahlung betreten. Du wirst nach dem Schliessen vom "
+"Popup zur Bezahlseite weitergeleitet."
msgid "Thank you for the order."
msgstr "Danke für Deine Bestellung."
@@ -517,8 +519,14 @@ msgid ""
"Your VM will be up and running in a few moments. We will send you a "
"confirmation email as soon as it is ready."
msgstr ""
-"Deine VM ist gleich bereit. Wir senden Dir eine Bestätigungsemail, sobald Du"
-" auf sie zugreifen kannst."
+"Deine VM ist gleich bereit. Wir senden Dir eine Bestätigungsemail, sobald Du "
+"auf sie zugreifen kannst."
+
+#~ msgid "Pricing"
+#~ msgstr "Preise"
+
+#~ msgid "Order VM"
+#~ msgstr "VM bestellen"
#~ msgid "Enter name"
#~ msgstr "Name"
@@ -533,18 +541,19 @@ msgstr ""
#~ msgstr "Anfrage verschickt"
#~ msgid ""
-#~ "Thank you for your subscription! You will receive a confirmation mail from "
-#~ "our team"
+#~ "Thank you for your subscription! You will receive a confirmation mail "
+#~ "from our team"
#~ msgstr ""
-#~ "Vielen dank für Ihre Anmeldung. Sie erhalten in kürze eine Bestätigungsmail "
-#~ "von unserem Team"
+#~ "Vielen dank für Ihre Anmeldung. Sie erhalten in kürze eine "
+#~ "Bestätigungsmail von unserem Team"
#~ msgid "Thank you for your request."
#~ msgstr "Vielen Dank für Deine Anfrage."
#~ msgid "You are one step away from being our beta tester!"
#~ msgstr ""
-#~ "Sie sind nur noch einen Schritt davon entfernt, unser Beta-Tester zu werden!"
+#~ "Sie sind nur noch einen Schritt davon entfernt, unser Beta-Tester zu "
+#~ "werden!"
#~ msgid ""
#~ "Currently we are running our tests to make sure everything runs perfectly."
@@ -553,8 +562,8 @@ msgstr ""
#~ "sicherzustellen."
#~ msgid ""
-#~ "In the meantime, we would like to ask you a little patience until our "
-#~ "team contacts you with beta access."
+#~ "In the meantime, we would like to ask you a little patience until "
+#~ "our team contacts you with beta access."
#~ msgstr ""
#~ "Wir werden dann sobald als möglich Ihren Beta-Zugang erstellen und Sie "
#~ "daraufhin kontaktieren.Bis dahin bitten wir Sie um etwas Geduld."
@@ -564,8 +573,8 @@ msgstr ""
#~ msgid "Thank you for order! Our team will contact you via email"
#~ msgstr ""
-#~ "Vielen Dank für die Bestellung. Unser Team setzt sich sobald wie möglich mit"
-#~ " Dir via E-Mail in Verbindung."
+#~ "Vielen Dank für die Bestellung. Unser Team setzt sich sobald wie möglich "
+#~ "mit Dir via E-Mail in Verbindung."
#~ msgid "Affordable VM hosting based in Switzerland"
#~ msgstr "Bezahlbares VM Hosting in der Schweiz"
@@ -581,18 +590,18 @@ msgstr ""
#~ msgid ""
#~ "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."
+#~ "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."
#~ msgstr ""
-#~ "Unsere VMs werden in der Schweiz im Kanton Glarus gehostet und befinden sich"
-#~ " zur Zeit noch in der BETA-Phase. Möchtest du mehr über uns erfahren und "
-#~ "hast auf unserer Website nicht genügend Informationen gefunden? Möchtest "
-#~ "eine detailliertere Bestellung aufgeben? Bist du auf technische Probleme "
-#~ "gestossen, die du uns mitteilen möchtest? Dann zögere nicht und kontaktiere "
-#~ "uns unter support@datacenterlight.ch. Unser Team wird sich umgehend um dein "
-#~ "Anliegen kümmern!"
+#~ "Unsere VMs werden in der Schweiz im Kanton Glarus gehostet und befinden "
+#~ "sich zur Zeit noch in der BETA-Phase. Möchtest du mehr über uns erfahren "
+#~ "und hast auf unserer Website nicht genügend Informationen gefunden? "
+#~ "Möchtest eine detailliertere Bestellung aufgeben? Bist du auf technische "
+#~ "Probleme gestossen, die du uns mitteilen möchtest? Dann zögere nicht und "
+#~ "kontaktiere uns unter support@datacenterlight.ch. Unser Team wird sich "
+#~ "umgehend um dein Anliegen kümmern!"
#~ msgid "is not a proper name"
#~ msgstr "ist kein gültiger Name"
@@ -610,12 +619,14 @@ msgstr ""
#~ "\n"
#~ "Hi,\n"
#~ "\n"
-#~ "You can activate your %(dcl_text)s account by clicking here %(base_url)s%(activation_link)s\n"
+#~ "You can activate your %(dcl_text)s account by clicking here %(base_url)s"
+#~ "%(activation_link)s\n"
#~ msgstr ""
#~ "\n"
#~ "Hallo,\n"
#~ "\n"
-#~ "Du kannst deinen %(dcl_text)s Account aktivieren, indem du hier klickst %(base_url)s%(activation_link)s\n"
+#~ "Du kannst deinen %(dcl_text)s Account aktivieren, indem du hier klickst "
+#~ "%(base_url)s%(activation_link)s\n"
#~ msgid "Your"
#~ msgstr "Dein"
@@ -650,12 +661,14 @@ msgstr ""
#~ msgid "I want to have it!"
#~ msgstr "Das möchte ich haben!"
-#~ msgid "Reuse existing factory halls intead of building an expensive building."
+#~ msgid ""
+#~ "Reuse existing factory halls intead of building an expensive building."
#~ msgstr ""
#~ "Nachhaltigkeit: Wiederverwendung ehemaliger Fabrikhallen an Stelle der "
#~ "Errichtung eines neuen Gebäudes"
-#~ msgid "Being creative, using modern and alternative design for a datacenter."
+#~ msgid ""
+#~ "Being creative, using modern and alternative design for a datacenter."
#~ msgstr ""
#~ "Kreativität: Verwendung eines modernen und alternativen Designs für unser "
#~ "Datencenter"
@@ -678,8 +691,8 @@ msgstr ""
#~ msgstr "Standort des Datacenters ist in der Schweiz"
#~ msgid ""
-#~ " WARNING: We are currently running in BETA mode. We hope you won't encounter"
-#~ " any hiccups, but if you do, please let us know at "
+#~ " WARNING: We are currently running in BETA mode. We hope you won't "
+#~ "encounter any hiccups, but if you do, please let us know at "
#~ "support@datacenterlight.ch"
#~ msgstr ""
#~ " Achtung: Wir befinden uns zurzeit im Beta-Release. Wir hoffen, dass Sie "
@@ -693,8 +706,8 @@ msgstr ""
#~ msgstr "Unser Versprechen"
#~ msgid ""
-#~ "Instead of creating an expensive SLA for availability, we promise that we do"
-#~ " our best to run things as smooth as possible."
+#~ "Instead of creating an expensive SLA for availability, we promise that we "
+#~ "do our best to run things as smooth as possible."
#~ msgstr ""
#~ "Anstatt eines SLAs (Service Levle Agreements) zu vereinbaren,setzen wir "
#~ "unsere persönliche Arbeitskraft ein, um Ihnen ein sorgenfreiesHosting zu "
From c92bf305144b744831c9e9eabd0e5ab0868cd109 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:23:09 +0200
Subject: [PATCH 47/74] Associate HostingOrder and VMPricing
---
.../0044_hostingorder_vm_pricing.py | 23 +++++++++++++++++++
hosting/models.py | 3 +++
2 files changed, 26 insertions(+)
create mode 100644 hosting/migrations/0044_hostingorder_vm_pricing.py
diff --git a/hosting/migrations/0044_hostingorder_vm_pricing.py b/hosting/migrations/0044_hostingorder_vm_pricing.py
new file mode 100644
index 00000000..ff36be3f
--- /dev/null
+++ b/hosting/migrations/0044_hostingorder_vm_pricing.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2018-04-16 00:22
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('datacenterlight', '0019_auto_20180415_2236'),
+ ('hosting', '0043_vmdetail'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='hostingorder',
+ name='vm_pricing',
+ field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='datacenterlight.VMPricing'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/hosting/models.py b/hosting/models.py
index 04f3ae30..de5732bc 100644
--- a/hosting/models.py
+++ b/hosting/models.py
@@ -6,6 +6,8 @@ from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from Crypto.PublicKey import RSA
+
+from datacenterlight.models import VMPricing
from membership.models import StripeCustomer, CustomUser
from utils.models import BillingAddress
from utils.mixins import AssignPermissionsMixin
@@ -53,6 +55,7 @@ class HostingOrder(AssignPermissionsMixin, models.Model):
stripe_charge_id = models.CharField(max_length=100, null=True)
price = models.FloatField()
subscription_id = models.CharField(max_length=100, null=True)
+ vm_pricing = models.ForeignKey(VMPricing)
permissions = ('view_hostingorder',)
From 85b8c50ef1668c89ea3553d5f6581f3e5ba84614 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:25:36 +0200
Subject: [PATCH 48/74] Use proper decimal arithmetic to compute price and vat
---
utils/hosting_utils.py | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py
index 1367138c..87b69534 100644
--- a/utils/hosting_utils.py
+++ b/utils/hosting_utils.py
@@ -1,3 +1,4 @@
+import decimal
import logging
from oca.pool import WrongIdError
@@ -72,13 +73,16 @@ def get_vm_price(cpu, memory, disk_size, hdd_size=0, pricing_name='default'):
)
)
return None
- return ((cpu * pricing.cores_unit_price) +
- (memory * pricing.ram_unit_price) +
- (disk_size * pricing.ssd_unit_price) +
- (hdd_size * pricing.hdd_unit_price))
+ price = ((decimal.Decimal(cpu) * pricing.cores_unit_price) +
+ (decimal.Decimal(memory) * pricing.ram_unit_price) +
+ (decimal.Decimal(disk_size) * pricing.ssd_unit_price) +
+ (decimal.Decimal(hdd_size) * pricing.hdd_unit_price))
+ cents = decimal.Decimal('.01')
+ price = price.quantize(cents, decimal.ROUND_HALF_UP)
+ return float(price)
-def get_vm_price_with_vat(cpu, memory, disk_size, hdd_size=0,
+def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0,
pricing_name='default'):
"""
A helper function that computes price of a VM from given cpu, ram and
@@ -86,7 +90,7 @@ def get_vm_price_with_vat(cpu, memory, disk_size, hdd_size=0,
:param cpu: Number of cores of the VM
:param memory: RAM of the VM
- :param disk_size: Disk space of the VM (SSD)
+ :param ssd_size: Disk space of the VM (SSD)
:param hdd_size: The HDD size
:param pricing_name: The pricing name to be used
:return: The a tuple containing the price of the VM and the VAT
@@ -102,12 +106,16 @@ def get_vm_price_with_vat(cpu, memory, disk_size, hdd_size=0,
)
return None
- price = float((cpu * pricing.cores_unit_price) +
- (memory * pricing.ram_unit_price) +
- (disk_size * pricing.ssd_unit_price) +
- (hdd_size * pricing.hdd_unit_price))
+ price = ((decimal.Decimal(cpu) * pricing.cores_unit_price) +
+ (decimal.Decimal(memory) * pricing.ram_unit_price) +
+ (decimal.Decimal(ssd_size) * pricing.ssd_unit_price) +
+ (decimal.Decimal(hdd_size) * pricing.hdd_unit_price))
if pricing.vat_inclusive:
- vat = 0
+ vat = decimal.Decimal(0)
else:
- vat = price * float(pricing.vat_percentage) * 0.01
- return price, vat
+ vat = price * pricing.vat_percentage * decimal.Decimal(0.01)
+
+ cents = decimal.Decimal('.01')
+ price = price.quantize(cents, decimal.ROUND_HALF_UP)
+ vat = vat.quantize(cents, decimal.ROUND_HALF_UP)
+ return float(price), float(vat)
From 0b9c67166e7f614bd0b167473199a3328c21bd31 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:26:51 +0200
Subject: [PATCH 49/74] Rename variable name: disk_size -> ssd_size
---
datacenterlight/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index e76ef31d..87a0e660 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -161,7 +161,7 @@ class IndexView(CreateView):
price, vat = get_vm_price_with_vat(
cpu=cores,
memory=memory,
- disk_size=storage,
+ ssd_size=storage,
pricing_name=vm_pricing_name
)
specs = {
From a8339a23a970358ea91b14cbf859a948402563df Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:27:54 +0200
Subject: [PATCH 50/74] Use get_vm_price_with_vat in hosting invoice
---
hosting/views.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hosting/views.py b/hosting/views.py
index 6e143760..4670c5d5 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -42,7 +42,7 @@ from utils.forms import (
BillingAddressForm, PasswordResetRequestForm, UserBillingAddressForm,
ResendActivationEmailForm
)
-from utils.hosting_utils import get_vm_price
+from utils.hosting_utils import get_vm_price, get_vm_price_with_vat
from utils.mailer import BaseEmail
from utils.stripe_utils import StripeUtils
from utils.tasks import send_plain_email_task
@@ -749,11 +749,13 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
context['vm'] = vm_detail.__dict__
context['vm']['name'] = '{}-{}'.format(
context['vm']['configuration'], context['vm']['vm_id'])
- context['vm']['price'] = get_vm_price(
+ price, vat = get_vm_price_with_vat(
cpu=context['vm']['cores'],
- disk_size=context['vm']['disk_size'],
- memory=context['vm']['memory']
+ ssd_size=context['vm']['disk_size'],
+ memory=context['vm']['memory'],
+ pricing_name=obj.pricing.name if obj.pricing else 'default'
)
+ context['vm']['price'] = price + vat
context['subscription_end_date'] = vm_detail.end_date()
except VMDetail.DoesNotExist:
try:
From 25c0694b6cba2df240a803e12be8b44db0db03ac Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:36:56 +0200
Subject: [PATCH 51/74] Use vm_pricing for creating HostingOrder
---
hosting/models.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hosting/models.py b/hosting/models.py
index de5732bc..09c6eb2a 100644
--- a/hosting/models.py
+++ b/hosting/models.py
@@ -73,12 +73,13 @@ class HostingOrder(AssignPermissionsMixin, models.Model):
@classmethod
def create(cls, price=None, vm_id=None, customer=None,
- billing_address=None):
+ billing_address=None, vm_pricing=None):
instance = cls.objects.create(
price=price,
vm_id=vm_id,
customer=customer,
- billing_address=billing_address
+ billing_address=billing_address,
+ vm_pricing=vm_pricing
)
instance.assign_permissions(customer.user)
return instance
From b103772c0d6148eb4c0614e787299b76d16b9383 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 03:37:19 +0200
Subject: [PATCH 52/74] Pass vm_pricing if available when creating HostingOrder
---
datacenterlight/tasks.py | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py
index df91387e..c97c6c54 100644
--- a/datacenterlight/tasks.py
+++ b/datacenterlight/tasks.py
@@ -97,13 +97,26 @@ def create_vm_task(self, vm_template_id, user, specs, template,
if vm_id is None:
raise Exception("Could not create VM")
- # Create a Hosting Order
- order = HostingOrder.create(
- price=final_price,
- vm_id=vm_id,
- customer=customer,
- billing_address=billing_address
- )
+ if 'pricing_name' in specs:
+ vm_pricing = VMPricing.get_vm_pricing_by_name(
+ name=specs['pricing_name']
+ )
+ # Create a Hosting Order
+ order = HostingOrder.create(
+ price=final_price,
+ vm_id=vm_id,
+ customer=customer,
+ billing_address=billing_address,
+ vm_pricing=vm_pricing
+ )
+ else:
+ # Create a Hosting Order
+ order = HostingOrder.create(
+ price=final_price,
+ vm_id=vm_id,
+ customer=customer,
+ billing_address=billing_address
+ )
# Create a Hosting Bill
HostingBill.create(
From b71fec7e6159b41e8825b1562c48ecf108cd8bcf Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:00:48 +0200
Subject: [PATCH 53/74] Fix a bug: use vm_pricing instead of pricing
---
hosting/views.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hosting/views.py b/hosting/views.py
index 4670c5d5..ca40f205 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -753,7 +753,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
cpu=context['vm']['cores'],
ssd_size=context['vm']['disk_size'],
memory=context['vm']['memory'],
- pricing_name=obj.pricing.name if obj.pricing else 'default'
+ pricing_name=(obj.vm_pricing.name
+ if obj.vm_pricing else 'default')
)
context['vm']['price'] = price + vat
context['subscription_end_date'] = vm_detail.end_date()
From adbb8a269ee995f54476fb93843a4eb0b31877d1 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:16:38 +0200
Subject: [PATCH 54/74] Hostingorders: limit amount to 2 decimal places
---
hosting/templates/hosting/orders.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hosting/templates/hosting/orders.html b/hosting/templates/hosting/orders.html
index f896c98b..140cc4c6 100644
--- a/hosting/templates/hosting/orders.html
+++ b/hosting/templates/hosting/orders.html
@@ -29,7 +29,7 @@
{{ order.id }}
{{ order.created_at | date:"M d, Y H:i" }}
- {{ order.price|intcomma }}
+ {{ order.price|floatformat:2|intcomma }}
{% trans 'See Invoice' %}
From 5738dc8e1b5b2d2323a2e6a4c20f9039511a7715 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:31:42 +0200
Subject: [PATCH 55/74] Virtual machine detail: use hostingorder for obtaining
the price, rather than the serializer
---
hosting/templates/hosting/virtual_machine_detail.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html
index b77e1dca..61b16112 100644
--- a/hosting/templates/hosting/virtual_machine_detail.html
+++ b/hosting/templates/hosting/virtual_machine_detail.html
@@ -45,7 +45,7 @@
{% trans "Billing" %}
{% trans "Current Pricing" %}
-
{{virtual_machine.price|floatformat|intcomma}} CHF/{% trans "Month" %}
+
{{order.price|floatformat|intcomma}} CHF/{% trans "Month" %}
{% trans "See Invoice" %}
From 602ad1b2c07986a3e65a48c4fbfedc4735f32c3e Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:32:27 +0200
Subject: [PATCH 56/74] Reformat code
---
hosting/views.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hosting/views.py b/hosting/views.py
index ca40f205..56f9386a 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -1103,7 +1103,8 @@ class VirtualMachineView(LoginRequiredMixin, View):
context = {
'virtual_machine': serializer.data,
'order': HostingOrder.objects.get(
- vm_id=serializer.data['vm_id'])
+ vm_id=serializer.data['vm_id']
+ )
}
except Exception as ex:
logger.debug("Exception generated {}".format(str(ex)))
From 6cc40cb67f68c0da20370748a7fd1ec94fb38367 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:34:40 +0200
Subject: [PATCH 57/74] virtual machine detail: show price upto 2 decimal
places
---
hosting/templates/hosting/virtual_machine_detail.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html
index 61b16112..68894851 100644
--- a/hosting/templates/hosting/virtual_machine_detail.html
+++ b/hosting/templates/hosting/virtual_machine_detail.html
@@ -45,7 +45,7 @@
{% trans "Billing" %}
{% trans "Current Pricing" %}
-
{{order.price|floatformat|intcomma}} CHF/{% trans "Month" %}
+
{{order.price|floatformat:2|intcomma}} CHF/{% trans "Month" %}
{% trans "See Invoice" %}
From 731fef8ad9c8735f3b746a5e9caeacd63192ae93 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:39:21 +0200
Subject: [PATCH 58/74] Show VAT details in hosting/order_details if it is set
---
hosting/templates/hosting/order_detail.html | 6 ++++++
hosting/views.py | 1 +
2 files changed, 7 insertions(+)
diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html
index f5ee80b6..099aaab8 100644
--- a/hosting/templates/hosting/order_detail.html
+++ b/hosting/templates/hosting/order_detail.html
@@ -127,6 +127,12 @@
{% trans "Disk space" %}:
{{vm.disk_size}} GB
+ {% if vm.vat > 0 %}
+
+ {% trans "VAT" %}:
+ {{vm.vat|floatformat:2|intcomma}} CHF
+
+ {% endif %}
{% trans "Total" %}
{{vm.price|intcomma}} CHF
diff --git a/hosting/views.py b/hosting/views.py
index 56f9386a..1f531784 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -756,6 +756,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
pricing_name=(obj.vm_pricing.name
if obj.vm_pricing else 'default')
)
+ context['vm']['vat'] = vat
context['vm']['price'] = price + vat
context['subscription_end_date'] = vm_detail.end_date()
except VMDetail.DoesNotExist:
From 1e768648217b8a2120161858e106a7e3372bce05 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 04:46:43 +0200
Subject: [PATCH 59/74] Get vm price and vat and pass it to context
---
hosting/views.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hosting/views.py b/hosting/views.py
index 1f531784..88593969 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -766,6 +766,15 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
)
vm = manager.get_vm(obj.vm_id)
context['vm'] = VirtualMachineSerializer(vm).data
+ price, vat = get_vm_price_with_vat(
+ cpu=context['vm']['cores'],
+ ssd_size=context['vm']['disk_size'],
+ memory=context['vm']['memory'],
+ pricing_name=(obj.vm_pricing.name
+ if obj.vm_pricing else 'default')
+ )
+ context['vm']['vat'] = vat
+ context['vm']['price'] = price + vat
except WrongIdError:
messages.error(
self.request,
From 3fca9dbb0df0d564f73a111d13c9c8eae825836f Mon Sep 17 00:00:00 2001
From: PCoder
Date: Mon, 16 Apr 2018 05:03:48 +0200
Subject: [PATCH 60/74] Fix a bug creating hostingorder
---
datacenterlight/tasks.py | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py
index c97c6c54..db479b43 100644
--- a/datacenterlight/tasks.py
+++ b/datacenterlight/tasks.py
@@ -97,30 +97,22 @@ def create_vm_task(self, vm_template_id, user, specs, template,
if vm_id is None:
raise Exception("Could not create VM")
- if 'pricing_name' in specs:
- vm_pricing = VMPricing.get_vm_pricing_by_name(
- name=specs['pricing_name']
- )
- # Create a Hosting Order
- order = HostingOrder.create(
- price=final_price,
- vm_id=vm_id,
- customer=customer,
- billing_address=billing_address,
- vm_pricing=vm_pricing
- )
- else:
- # Create a Hosting Order
- order = HostingOrder.create(
- price=final_price,
- vm_id=vm_id,
- customer=customer,
- billing_address=billing_address
- )
+ vm_pricing = VMPricing.get_vm_pricing_by_name(
+ name=specs['pricing_name']
+ ) if 'pricing_name' in specs else VMPricing.get_default_pricing()
+ # Create a Hosting Order
+ order = HostingOrder.create(
+ price=final_price,
+ vm_id=vm_id,
+ customer=customer,
+ billing_address=billing_address,
+ vm_pricing=vm_pricing
+ )
# Create a Hosting Bill
HostingBill.create(
- customer=customer, billing_address=billing_address)
+ customer=customer, billing_address=billing_address
+ )
# Create Billing Address for User if he does not have one
if not customer.user.billing_addresses.count():
From d15a4da84061798ca824dd271dad704459e8d159 Mon Sep 17 00:00:00 2001
From: "M.Ravi"
Date: Tue, 17 Apr 2018 18:03:10 +0200
Subject: [PATCH 61/74] Check if child plugin instances exist before looping
over them
---
datacenterlight/cms_plugins.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index 2ad07249..6533adc7 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -92,13 +92,14 @@ class DCLCalculatorPlugin(CMSPluginBase):
context['children_to_side'] = []
context['children_to_content'] = []
pricing_plugin_model = None
- for child in instance.child_plugin_instances:
- if child.__class__.__name__ == 'DCLCustomPricingModel':
- # The second clause is just to make sure we pick up the most
- # recent CustomPricing, if more than one is present
- if (pricing_plugin_model is None or child.pricing_id >
- pricing_plugin_model.model.pricing_id):
- pricing_plugin_model = child
+ if instance.child_plugin_instances:
+ for child in instance.child_plugin_instances:
+ if child.__class__.__name__ == 'DCLCustomPricingModel':
+ # The second clause is just to make sure we pick up the
+ # most recent CustomPricing, if more than one is present
+ if (pricing_plugin_model is None or child.pricing_id >
+ pricing_plugin_model.model.pricing_id):
+ pricing_plugin_model = child
if pricing_plugin_model:
context['vm_pricing'] = VMPricing.get_vm_pricing_by_name(
From e4e7d93275c2306154704152e9ce1b06c3d5c282 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 20:50:41 +0200
Subject: [PATCH 62/74] Fix flake8 errors
---
datacenterlight/admin.py | 1 +
utils/hosting_utils.py | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py
index 3e5927e8..28adf28b 100644
--- a/datacenterlight/admin.py
+++ b/datacenterlight/admin.py
@@ -7,5 +7,6 @@ from .models import VMPricing
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
list_display = ('name', 'domain')
+
admin.site.register(CMSIntegration, CMSIntegrationAdmin)
admin.site.register(VMPricing)
diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py
index 87b69534..c267cc0b 100644
--- a/utils/hosting_utils.py
+++ b/utils/hosting_utils.py
@@ -74,9 +74,9 @@ def get_vm_price(cpu, memory, disk_size, hdd_size=0, pricing_name='default'):
)
return None
price = ((decimal.Decimal(cpu) * pricing.cores_unit_price) +
- (decimal.Decimal(memory) * pricing.ram_unit_price) +
- (decimal.Decimal(disk_size) * pricing.ssd_unit_price) +
- (decimal.Decimal(hdd_size) * pricing.hdd_unit_price))
+ (decimal.Decimal(memory) * pricing.ram_unit_price) +
+ (decimal.Decimal(disk_size) * pricing.ssd_unit_price) +
+ (decimal.Decimal(hdd_size) * pricing.hdd_unit_price))
cents = decimal.Decimal('.01')
price = price.quantize(cents, decimal.ROUND_HALF_UP)
return float(price)
From a50fa77c8a9f7598b7a12e7741ad9b02a8236b13 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 21:36:08 +0200
Subject: [PATCH 63/74] Update get_vm_price_with_vat: Return vat_percentage
also
---
utils/hosting_utils.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py
index c267cc0b..04ed658a 100644
--- a/utils/hosting_utils.py
+++ b/utils/hosting_utils.py
@@ -93,7 +93,8 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0,
:param ssd_size: Disk space of the VM (SSD)
:param hdd_size: The HDD size
:param pricing_name: The pricing name to be used
- :return: The a tuple containing the price of the VM and the VAT
+ :return: The a tuple containing the price of the VM, the VAT and the
+ VAT percentage
"""
try:
pricing = VMPricing.objects.get(name=pricing_name)
@@ -112,10 +113,12 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0,
(decimal.Decimal(hdd_size) * pricing.hdd_unit_price))
if pricing.vat_inclusive:
vat = decimal.Decimal(0)
+ vat_percent = decimal.Decimal(0)
else:
vat = price * pricing.vat_percentage * decimal.Decimal(0.01)
+ vat_percent = pricing.vat_percentage
cents = decimal.Decimal('.01')
price = price.quantize(cents, decimal.ROUND_HALF_UP)
vat = vat.quantize(cents, decimal.ROUND_HALF_UP)
- return float(price), float(vat)
+ return float(price), float(vat), float(vat_percent)
From c2513dc7c3527afc4f94cb577062a47c9a906d74 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 21:38:28 +0200
Subject: [PATCH 64/74] Show vat_percent and subtotal for vat exclusive case
---
datacenterlight/templates/datacenterlight/order_detail.html | 6 +++++-
datacenterlight/views.py | 3 ++-
hosting/views.py | 4 ++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html
index f26bc450..543f3934 100644
--- a/datacenterlight/templates/datacenterlight/order_detail.html
+++ b/datacenterlight/templates/datacenterlight/order_detail.html
@@ -67,7 +67,11 @@
{% if vm.vat > 0 %}
- {% trans "VAT" %}:
+ {% trans "Subtotal" %}:
+ {{vm.price|floatformat:2|intcomma}} CHF
+
+
+ {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%):
{{vm.vat|floatformat:2|intcomma}} CHF
{% endif %}
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index 87a0e660..cccd4277 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -158,7 +158,7 @@ class IndexView(CreateView):
)
return HttpResponseRedirect(referer_url + "#order_form")
- price, vat = get_vm_price_with_vat(
+ price, vat, vat_percent = get_vm_price_with_vat(
cpu=cores,
memory=memory,
ssd_size=storage,
@@ -170,6 +170,7 @@ class IndexView(CreateView):
'disk_size': storage,
'price': price,
'vat': vat,
+ 'vat_percent': vat_percent,
'total_price': price + vat,
'pricing_name': vm_pricing_name
}
diff --git a/hosting/views.py b/hosting/views.py
index 88593969..a7aeca1e 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -749,7 +749,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
context['vm'] = vm_detail.__dict__
context['vm']['name'] = '{}-{}'.format(
context['vm']['configuration'], context['vm']['vm_id'])
- price, vat = get_vm_price_with_vat(
+ price, vat, vat_percent = get_vm_price_with_vat(
cpu=context['vm']['cores'],
ssd_size=context['vm']['disk_size'],
memory=context['vm']['memory'],
@@ -766,7 +766,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
)
vm = manager.get_vm(obj.vm_id)
context['vm'] = VirtualMachineSerializer(vm).data
- price, vat = get_vm_price_with_vat(
+ price, vat, vat_percent = get_vm_price_with_vat(
cpu=context['vm']['cores'],
ssd_size=context['vm']['disk_size'],
memory=context['vm']['memory'],
From a454cd252280c383da0b475433773340c1b73abc Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 21:38:53 +0200
Subject: [PATCH 65/74] Update datacenterlight's django.po
---
datacenterlight/locale/de/LC_MESSAGES/django.po | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po
index 3dc4650b..b937805c 100644
--- a/datacenterlight/locale/de/LC_MESSAGES/django.po
+++ b/datacenterlight/locale/de/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-04-15 23:37+0000\n"
+"POT-Creation-Date: 2018-04-17 19:26+0000\n"
"PO-Revision-Date: 2018-03-30 23:22+0000\n"
"Last-Translator: b'Anonymous User '\n"
"Language-Team: LANGUAGE \n"
@@ -97,6 +97,7 @@ msgstr "Deine E-Mail-Adresse"
msgid "Password"
msgstr "Passwort"
+#, python-format
msgid ""
"You can reset your password here ."
@@ -379,15 +380,20 @@ msgstr "Bestellungsübersicht"
msgid "Product"
msgstr "Produkt"
+#, fuzzy
+msgid "Subtotal"
+msgstr "Zwischensumme"
+
msgid "VAT"
msgstr "Mehrwertsteuer"
+#, python-format
msgid ""
"By clicking \"Place order\" this plan will charge your credit card account "
"with the fee of %(vm_total_price)s CHF/month"
msgstr ""
-"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_total_price)s CHF "
-"pro Monat belastet"
+"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit "
+"%(vm_total_price)s CHF pro Monat belastet"
msgid "Place order"
msgstr "Bestellen"
From 4c21110c00807b5c44849768c4bcaac174f13b50 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 21:47:02 +0200
Subject: [PATCH 66/74] Remove fuzzy and python-format
---
datacenterlight/locale/de/LC_MESSAGES/django.po | 2 --
1 file changed, 2 deletions(-)
diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po
index b937805c..50dbfbe8 100644
--- a/datacenterlight/locale/de/LC_MESSAGES/django.po
+++ b/datacenterlight/locale/de/LC_MESSAGES/django.po
@@ -380,14 +380,12 @@ msgstr "Bestellungsübersicht"
msgid "Product"
msgstr "Produkt"
-#, fuzzy
msgid "Subtotal"
msgstr "Zwischensumme"
msgid "VAT"
msgstr "Mehrwertsteuer"
-#, python-format
msgid ""
"By clicking \"Place order\" this plan will charge your credit card account "
"with the fee of %(vm_total_price)s CHF/month"
From 2ac1ac7d9728db5ec30e434aae0495c19385c3a2 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 22:20:36 +0200
Subject: [PATCH 67/74] Add subtotal and VAT to hosting order detail too
---
hosting/templates/hosting/order_detail.html | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html
index 099aaab8..45b68cae 100644
--- a/hosting/templates/hosting/order_detail.html
+++ b/hosting/templates/hosting/order_detail.html
@@ -129,13 +129,17 @@
{% if vm.vat > 0 %}
- {% trans "VAT" %}:
+ {% trans "Subtotal" %}:
+ {{vm.price|floatformat:2|intcomma}} CHF
+
+
+ {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%):
{{vm.vat|floatformat:2|intcomma}} CHF
{% endif %}
{% trans "Total" %}
- {{vm.price|intcomma}} CHF
+ {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF
From 36c0b9a0a67a474dcb395dafdc75cd3329312e74 Mon Sep 17 00:00:00 2001
From: PCoder
Date: Tue, 17 Apr 2018 22:23:46 +0200
Subject: [PATCH 68/74] Differentiate price and total_price in hosting
order_detail
---
hosting/views.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hosting/views.py b/hosting/views.py
index a7aeca1e..ec36836a 100644
--- a/hosting/views.py
+++ b/hosting/views.py
@@ -757,7 +757,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
if obj.vm_pricing else 'default')
)
context['vm']['vat'] = vat
- context['vm']['price'] = price + vat
+ context['vm']['price'] = price
+ context['vm']['vat_percent'] = vat_percent
+ context['vm']['total_price'] = price + vat
context['subscription_end_date'] = vm_detail.end_date()
except VMDetail.DoesNotExist:
try:
@@ -774,7 +776,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
if obj.vm_pricing else 'default')
)
context['vm']['vat'] = vat
- context['vm']['price'] = price + vat
+ context['vm']['price'] = price
+ context['vm']['vat_percent'] = vat_percent
+ context['vm']['total_price'] = price + vat
except WrongIdError:
messages.error(
self.request,
From 4e3211b62fb08ae6835f71a2fba6aae015bb83ed Mon Sep 17 00:00:00 2001
From: PCoder
Date: Wed, 18 Apr 2018 21:37:12 +0200
Subject: [PATCH 69/74] Make total and subtotal texts bold
---
datacenterlight/templates/datacenterlight/order_detail.html | 4 ++--
hosting/templates/hosting/order_detail.html | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html
index 543f3934..95bfa3c6 100644
--- a/datacenterlight/templates/datacenterlight/order_detail.html
+++ b/datacenterlight/templates/datacenterlight/order_detail.html
@@ -67,7 +67,7 @@
{% if vm.vat > 0 %}
- {% trans "Subtotal" %}:
+ {% trans "Subtotal" %}:
{{vm.price|floatformat:2|intcomma}} CHF
@@ -76,7 +76,7 @@
{% endif %}
- {% trans "Total" %}
+ {% trans "Total" %}
{{vm.total_price|floatformat:2|intcomma}} CHF
diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html
index 45b68cae..2568aafc 100644
--- a/hosting/templates/hosting/order_detail.html
+++ b/hosting/templates/hosting/order_detail.html
@@ -129,7 +129,7 @@
{% if vm.vat > 0 %}
- {% trans "Subtotal" %}:
+ {% trans "Subtotal" %}:
{{vm.price|floatformat:2|intcomma}} CHF
@@ -138,7 +138,7 @@
{% endif %}
- {% trans "Total" %}
+ {% trans "Total" %}
{% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF
From da13903ba2ebb1c83b784cf4fb14e5eb1b4170c0 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Fri, 20 Apr 2018 16:42:50 +0530
Subject: [PATCH 70/74] remove padding
---
datacenterlight/static/datacenterlight/css/header-slider.css | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/datacenterlight/static/datacenterlight/css/header-slider.css b/datacenterlight/static/datacenterlight/css/header-slider.css
index e21e2b49..d01f02a7 100644
--- a/datacenterlight/static/datacenterlight/css/header-slider.css
+++ b/datacenterlight/static/datacenterlight/css/header-slider.css
@@ -120,6 +120,11 @@
.header_slider .intro-cap {
font-size: 3.25em;
}
+
+ .header_slider > .carousel .item .container {
+ padding-left: 0;
+ padding-right: 0;
+ }
}
.header_slider .intro_lead {
From 1e97d0ba380a382a92f6e76a6e2014fb84b36141 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Fri, 20 Apr 2018 17:51:46 +0530
Subject: [PATCH 71/74] Update cms_plugins.py
---
datacenterlight/cms_plugins.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py
index 6533adc7..19dc0b39 100644
--- a/datacenterlight/cms_plugins.py
+++ b/datacenterlight/cms_plugins.py
@@ -89,10 +89,12 @@ class DCLCalculatorPlugin(CMSPluginBase):
context, instance, placeholder
)
context['templates'] = VMTemplate.objects.all()
- context['children_to_side'] = []
context['children_to_content'] = []
pricing_plugin_model = None
- if instance.child_plugin_instances:
+ if instance.child_plugin_instances is not None:
+ context['children_to_content'].extend(
+ instance.child_plugin_instances
+ )
for child in instance.child_plugin_instances:
if child.__class__.__name__ == 'DCLCustomPricingModel':
# The second clause is just to make sure we pick up the
@@ -108,10 +110,6 @@ class DCLCalculatorPlugin(CMSPluginBase):
else:
context['vm_pricing'] = VMPricing.get_default_pricing()
- if instance.child_plugin_instances is not None:
- context['children_to_content'].extend(
- instance.child_plugin_instances
- )
return context
From 8f6260b063269d127dbfff2eda68ad930672c77d Mon Sep 17 00:00:00 2001
From: Arvind Tiwari
Date: Fri, 20 Apr 2018 17:54:23 +0530
Subject: [PATCH 72/74] Update _calculator_form.html
---
.../includes/_calculator_form.html | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
index 05201b11..e3fe8676 100644
--- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
+++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html
@@ -1,14 +1,16 @@
{% load staticfiles i18n%}
+
{% if vm_pricing %}
-
+
{% endif %}
+