From b218ee1662677955759005ec2c95089f0d928414 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 17 Apr 2018 11:47:56 +0200 Subject: [PATCH 01/60] Add urlconfs for comic --- dynamicweb/urls.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index edb7e3b7..8f9f5b1c 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -11,6 +11,7 @@ from hosting.views import ( RailsHostingView, DjangoHostingView, NodeJSHostingView ) from membership import urls as membership_urls +from ungleich import views as ungleich_views from ungleich_page.views import LandingView from django.views.generic import RedirectView from django.core.urlresolvers import reverse_lazy @@ -60,6 +61,13 @@ urlpatterns += i18n_patterns( url=reverse_lazy('ungleich:post-list') ), name='blog_list_view' ), + url(r'^comic/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$', + RedirectView.as_view(pattern_name='ungleich:post-detail')), + url(r'^comic/$', + ungleich_views.PostListViewUngleich.as_view( + tags='comic' + ), + name='blog_list_view'), url(r'^cms/', include('cms.urls')), url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS else LandingView.as_view()), From ee35fbd7849f5d2d1ea49773038024928ba84351 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 17 Apr 2018 11:49:01 +0200 Subject: [PATCH 02/60] Attempt to filter blogs by category --- ungleich/views.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ungleich/views.py b/ungleich/views.py index 3610d1bc..36583a04 100644 --- a/ungleich/views.py +++ b/ungleich/views.py @@ -7,6 +7,7 @@ from djangocms_blog.models import Post from djangocms_blog.views import PostListView from djangocms_blog.settings import get_setting from django.utils.translation import ugettext_lazy as _ +from djangocms_blog.models import BlogCategory def blog(request): @@ -20,6 +21,7 @@ def blog(request): class PostListViewUngleich(PostListView): + tags = None model = Post context_object_name = 'post_list' base_template_name = 'post_list_ungleich.html' @@ -38,7 +40,17 @@ class PostListViewUngleich(PostListView): def get_queryset(self): language = get_language() - queryset = self.model.objects.filter(publish=True).translated(language) + if self.tags: + queryset = (self.model + .objects + .filter(tags__name__in=[self.tags], publish=True) + .translated(language)) + else: + queryset = (self.model + .objects + .filter(publish=True) + .translated(language) + ) setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config) return queryset From ff1d4f1a6fb211b7d72366e344d40dd3124b6328 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 16:15:49 +0200 Subject: [PATCH 03/60] Rename tags to category, because thats how we filter posts by --- dynamicweb/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 8f9f5b1c..20e9df3b 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -65,7 +65,7 @@ urlpatterns += i18n_patterns( RedirectView.as_view(pattern_name='ungleich:post-detail')), url(r'^comic/$', ungleich_views.PostListViewUngleich.as_view( - tags='comic' + category='comic' ), name='blog_list_view'), url(r'^cms/', include('cms.urls')), From 7d211b33333ebca6e559f2c46f7bd2dc220dc309 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 16:17:25 +0200 Subject: [PATCH 04/60] Modify PostListViewUngleich: Filter posts by category if specified --- ungleich/views.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ungleich/views.py b/ungleich/views.py index 36583a04..c1d7445d 100644 --- a/ungleich/views.py +++ b/ungleich/views.py @@ -21,7 +21,7 @@ def blog(request): class PostListViewUngleich(PostListView): - tags = None + category = None model = Post context_object_name = 'post_list' base_template_name = 'post_list_ungleich.html' @@ -40,10 +40,20 @@ class PostListViewUngleich(PostListView): def get_queryset(self): language = get_language() - if self.tags: + if self.category: + blog_category = ( + BlogCategory + ._default_manager + .language(language) + .filter( + translations__language_code=language, + translations__slug=self.category + ) + ) + queryset = (self.model .objects - .filter(tags__name__in=[self.tags], publish=True) + .filter(categories=blog_category, publish=True) .translated(language)) else: queryset = (self.model From 80a568b2b382a763f108d809249f2e71bf69ff0c Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 17:14:39 +0200 Subject: [PATCH 05/60] Remove unwanted /comic/... urlconf --- dynamicweb/urls.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 20e9df3b..09aa4fa8 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -61,8 +61,6 @@ urlpatterns += i18n_patterns( url=reverse_lazy('ungleich:post-list') ), name='blog_list_view' ), - url(r'^comic/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$', - RedirectView.as_view(pattern_name='ungleich:post-detail')), url(r'^comic/$', ungleich_views.PostListViewUngleich.as_view( category='comic' From 8b5b353e59a663cc5d9c3a678b549ca0aa1af2d1 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 17:15:23 +0200 Subject: [PATCH 06/60] Reformat code and give proper name to comic urlconf --- dynamicweb/urls.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index 09aa4fa8..50bc10ec 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -62,10 +62,8 @@ urlpatterns += i18n_patterns( ), name='blog_list_view' ), url(r'^comic/$', - ungleich_views.PostListViewUngleich.as_view( - category='comic' - ), - name='blog_list_view'), + ungleich_views.PostListViewUngleich.as_view(category='comic'), + name='comic_post_list_view'), url(r'^cms/', include('cms.urls')), url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS else LandingView.as_view()), From b3d36c1be3bf9485d8bedb89f0faf20a5ee6ded4 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 18:12:45 +0200 Subject: [PATCH 07/60] Reformat code --- ungleich/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ungleich/views.py b/ungleich/views.py index c1d7445d..af7cb304 100644 --- a/ungleich/views.py +++ b/ungleich/views.py @@ -59,8 +59,7 @@ class PostListViewUngleich(PostListView): queryset = (self.model .objects .filter(publish=True) - .translated(language) - ) + .translated(language)) setattr(self.request, get_setting('CURRENT_NAMESPACE'), self.config) return queryset From a7f1f14dc779173fc9f4dc9411748b886170c69a Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 19 Apr 2018 09:12:54 +0200 Subject: [PATCH 08/60] Raise Http404 when we do not have a post for a given language --- digitalglarus/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 32d8e1f5..a450b413 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -2,7 +2,7 @@ import logging from django.conf import settings from django.shortcuts import render -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, Http404 from django.core.urlresolvers import reverse_lazy, reverse from django.utils.translation import ugettext_lazy as _ from django.views.generic import TemplateView, UpdateView @@ -846,6 +846,8 @@ def blog_detail(request, slug): # post = Post.objects.filter_by_language(get_language()).filter(slug=slug).first() post = Post.objects.translated(get_language(), slug=slug).first() + if post is None: + raise Http404() context = { 'post': post, } From 0b97ae69f5d3d33f5a136b6b19cc71c1681dc3b6 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 19 Apr 2018 09:23:22 +0200 Subject: [PATCH 09/60] Cleanup and reformat some code --- digitalglarus/views.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index a450b413..f99577c5 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -834,8 +834,9 @@ class ContactView(FormView): def blog(request): tags = ["digitalglarus"] - posts = Post.objects.filter(tags__name__in=tags, publish=True).translated(get_language()) - # posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags, publish=True) + posts = (Post.objects + .filter(tags__name__in=tags, publish=True) + .translated(get_language())) context = { 'post_list': posts, } @@ -843,8 +844,6 @@ def blog(request): def blog_detail(request, slug): - # post = Post.objects.filter_by_language(get_language()).filter(slug=slug).first() - post = Post.objects.translated(get_language(), slug=slug).first() if post is None: raise Http404() From a25bcc807f6b09ef295edd677d52a0a60aa453a8 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 20 Apr 2018 17:04:02 +0530 Subject: [PATCH 10/60] change header slider to container fluid --- .../static/datacenterlight/css/header-slider.css | 11 +++-------- .../_header_with_background_video_slider_item.html | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/datacenterlight/static/datacenterlight/css/header-slider.css b/datacenterlight/static/datacenterlight/css/header-slider.css index d01f02a7..ea01edf7 100644 --- a/datacenterlight/static/datacenterlight/css/header-slider.css +++ b/datacenterlight/static/datacenterlight/css/header-slider.css @@ -55,7 +55,7 @@ flex: 1; } -.header_slider > .carousel .item .container { +.header_slider > .carousel .item .container-fluid { overflow: auto; padding: 50px 20px 60px; height: 100%; @@ -104,9 +104,9 @@ .header_slider .carousel-control .fa { font-size: 4em; } - .header_slider > .carousel .item .container { + .header_slider > .carousel .item .container-fluid { overflow: auto; - padding: 75px 50px; + padding: 75px; } .header_slider .btn-trans { padding: 8px 15px; @@ -120,11 +120,6 @@ .header_slider .intro-cap { font-size: 3.25em; } - - .header_slider > .carousel .item .container { - padding-left: 0; - padding-right: 0; - } } .header_slider .intro_lead { diff --git a/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_video_slider_item.html b/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_video_slider_item.html index f1edba16..4761cdc5 100644 --- a/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_video_slider_item.html +++ b/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_video_slider_item.html @@ -13,7 +13,7 @@ {% endif %} -
+
{% if instance.heading %}
{{ instance.heading }}
{% endif %} From 67a6c8f2c29616982b5142ca82a4efaa8f601d5d Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 21 Apr 2018 22:59:00 +0530 Subject: [PATCH 11/60] Update Changelog --- Changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 471f0720..cc53af19 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +1.7.1: 2018-04-21 + * #4481: [digitalglarus] Make /blog available on all domains + * #4370: [comic] new url /comic to show only comic blogs 1.7: 2018-04-20 * bgfix: [all] Make /blog available on all domains * #4367: [dcl] email logo resolution fix From 91f1c1ef0670be10e4df36e1671aa5e2408a19c3 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 21 Apr 2018 23:05:23 +0530 Subject: [PATCH 12/60] Update Changelog --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index cc53af19..86c21db0 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ 1.7.1: 2018-04-21 - * #4481: [digitalglarus] Make /blog available on all domains + * #4481: [blog] fix de blog pages 500 error * #4370: [comic] new url /comic to show only comic blogs 1.7: 2018-04-20 * bgfix: [all] Make /blog available on all domains From 3bf064a017d400f50ec72a8d652f4d72791eb812 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 14:52:25 +0530 Subject: [PATCH 13/60] add calculator placeholder to cms_integration --- datacenterlight/cms_models.py | 6 +- datacenterlight/cms_plugins.py | 67 ++++++++-------- ...1_cmsintegration_calculator_placeholder.py | 28 +++++++ .../datacenterlight/css/landing-page.css | 4 +- .../datacenterlight/cms/calculator.html | 17 +--- .../datacenterlight/cms/section.html | 15 +++- .../includes/_calculator_form.html | 4 +- dynamicweb/settings/base.py | 12 +++ .../static/hosting/css/price_calculator.css | 6 +- hosting/static/hosting/js/initial.js | 80 +++++++++++++++++++ hosting/templates/hosting/base_short.html | 9 ++- .../hosting/create_virtual_machine.html | 14 ++-- hosting/views.py | 7 +- 13 files changed, 195 insertions(+), 74 deletions(-) create mode 100644 datacenterlight/migrations/0021_cmsintegration_calculator_placeholder.py diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index dd6a165f..5a8d7ac8 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -26,6 +26,10 @@ class CMSIntegration(models.Model): navbar_placeholder = PlaceholderField( 'datacenterlight_navbar', related_name='dcl-navbar-placeholder+' ) + calculator_placeholder = PlaceholderField( + 'datacenterlight_calculator', + related_name='dcl-calculator-placeholder+' + ) domain = models.ForeignKey(Site, null=True, blank=True) class Meta: @@ -288,7 +292,7 @@ class DCLSectionPromoPluginModel(CMSPlugin): return extra_classes -class DCLCustomPricingModel(CMSPlugin): +class DCLCalculatorPluginModel(CMSPlugin): pricing = models.ForeignKey( VMPricing, related_name="dcl_custom_pricing_vm_pricing", diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 19dc0b39..0096faa5 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -1,3 +1,4 @@ +from cms.models.pluginmodel import CMSPlugin from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -6,7 +7,7 @@ from .cms_models import ( DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel, DCLSectionIconPluginModel, DCLSectionImagePluginModel, DCLSectionPluginModel, DCLNavbarPluginModel, - DCLSectionPromoPluginModel, DCLCustomPricingModel + DCLSectionPromoPluginModel, DCLCalculatorPluginModel ) from .models import VMTemplate, VMPricing @@ -21,7 +22,7 @@ class DCLSectionPlugin(CMSPluginBase): allow_children = True child_classes = [ 'DCLSectionIconPlugin', 'DCLSectionImagePlugin', - 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin' + 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin', 'DCLCalculatorPlugin' ] def render(self, context, instance, placeholder): @@ -30,14 +31,18 @@ class DCLSectionPlugin(CMSPluginBase): ) context['children_to_side'] = [] context['children_to_content'] = [] + context['children_calculator'] = [] if instance.child_plugin_instances is not None: right_children = [ 'DCLSectionImagePluginModel', - 'DCLSectionIconPluginModel' + 'DCLSectionIconPluginModel', ] for child in instance.child_plugin_instances: + print(child.__dict__) if child.__class__.__name__ in right_children: context['children_to_side'].append(child) + elif child.__class__.__name__ == 'CMSPlugin': + context['children_calculator'].append(child) else: context['children_to_content'].append(child) return context @@ -75,50 +80,42 @@ class DCLSectionPromoPlugin(CMSPluginBase): @plugin_pool.register_plugin class DCLCalculatorPlugin(CMSPluginBase): module = "Datacenterlight" - name = "DCL Calculator Section Plugin" - model = DCLSectionPluginModel + name = "DCL Calculator Plugin" + model = DCLCalculatorPluginModel render_template = "datacenterlight/cms/calculator.html" cache = False - allow_children = True - child_classes = [ - 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin', 'DCLCustomPricingPlugin' - ] + require_parent = True def render(self, context, instance, placeholder): context = super(DCLCalculatorPlugin, self).render( context, instance, placeholder ) context['templates'] = VMTemplate.objects.all() - context['children_to_content'] = [] - pricing_plugin_model = None - 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 - # 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() + # pricing_plugin_model = None + # if instance.child_plugin_instances is not 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() 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 DCLCustomPricingPlugin(CMSPluginBase): +# module = "Datacenterlight" +# name = "DCL Custom Pricing Plugin" +# model = DCLCustomPricingModel +# render_plugin = False @plugin_pool.register_plugin diff --git a/datacenterlight/migrations/0021_cmsintegration_calculator_placeholder.py b/datacenterlight/migrations/0021_cmsintegration_calculator_placeholder.py new file mode 100644 index 00000000..3ebbb469 --- /dev/null +++ b/datacenterlight/migrations/0021_cmsintegration_calculator_placeholder.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-04-25 09:20 +from __future__ import unicode_literals + +import cms.models.fields +from django.db import migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0020_merge'), + ('cms', '0014_auto_20160404_1908'), + ] + + operations = [ + migrations.AddField( + model_name='cmsintegration', + name='calculator_placeholder', + field=cms.models.fields.PlaceholderField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, + related_name='dcl-calculator-placeholder+', slotname='datacenterlight_calculator', to='cms.Placeholder'), + ), + migrations.RenameModel( + old_name='DCLCustomPricingModel', + new_name='DCLCalculatorPluginModel', + ), + ] diff --git a/datacenterlight/static/datacenterlight/css/landing-page.css b/datacenterlight/static/datacenterlight/css/landing-page.css index 8e9f2c2d..f241ed71 100755 --- a/datacenterlight/static/datacenterlight/css/landing-page.css +++ b/datacenterlight/static/datacenterlight/css/landing-page.css @@ -776,7 +776,7 @@ textarea { width: 100%; margin: 0 auto; background: #fff; - box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); + box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1), 0 0 6px rgba(0, 0, 0, 0.15); padding-bottom: 40px; border-radius: 7px; text-align: center; @@ -929,7 +929,7 @@ textarea { } -@media(max-width:991px) { +@media(max-width:767px) { .section-sm-center .split-text, .section-sm-center .space { text-align: center !important; diff --git a/datacenterlight/templates/datacenterlight/cms/calculator.html b/datacenterlight/templates/datacenterlight/cms/calculator.html index 27d1f89c..7b123a72 100644 --- a/datacenterlight/templates/datacenterlight/cms/calculator.html +++ b/datacenterlight/templates/datacenterlight/cms/calculator.html @@ -1,16 +1,5 @@ -
-
-
-
- {% include "datacenterlight/cms/includes/_section_split_content.html" %} -
-
-
-
- {% include "datacenterlight/includes/_calculator_form.html" %} -
-
-
-
+
+
+ {% include "datacenterlight/includes/_calculator_form.html" with vm_pricing=instance.pricing %}
\ No newline at end of file diff --git a/datacenterlight/templates/datacenterlight/cms/section.html b/datacenterlight/templates/datacenterlight/cms/section.html index 5a420a99..4438cf7d 100644 --- a/datacenterlight/templates/datacenterlight/cms/section.html +++ b/datacenterlight/templates/datacenterlight/cms/section.html @@ -2,17 +2,24 @@
- {% if children_to_side|length %} + {% if children_to_side|length or children_calculator|length %}
{% include "datacenterlight/cms/includes/_section_split_content.html" %}
-
- {% for plugin in children_to_side %} + {% if children_calculator|length %} + {% for plugin in children_calculator %} {% render_plugin plugin %} {% endfor %} -
+ {% endif %} + {% if children_to_side %} +
+ {% for plugin in children_to_side %} + {% render_plugin plugin %} + {% endfor %} +
+ {% endif %}
{% else %} diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index e3fe8676..656e78e7 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -17,7 +17,7 @@

{% trans "VM hosting" %}

- 15 + CHF/{% trans "month" %} {% if vm_pricing.vat_inclusive %}
@@ -94,4 +94,4 @@
- + \ No newline at end of file diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 58c6b8e2..da3f0941 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -352,6 +352,18 @@ CMS_PLACEHOLDER_CONF = { }, ] }, + 'datacenterlight_calculator': { + 'name': _('Datacenterlight Calculator'), + 'plugins': ['DCLCalculatorPlugin'], + 'default_plugins': [ + { + 'plugin_type': 'DCLCalculatorPlugin', + 'values': { + 'pricing_id': 1 + }, + }, + ] + }, } CMS_PERMISSION = True diff --git a/hosting/static/hosting/css/price_calculator.css b/hosting/static/hosting/css/price_calculator.css index 316b12ca..61fb277b 100644 --- a/hosting/static/hosting/css/price_calculator.css +++ b/hosting/static/hosting/css/price_calculator.css @@ -1,7 +1,7 @@ /* Create VM calculator */ .price-calc-section { - padding: 80px 40px !important; + padding: 20px 0 !important; } @media (max-width: 768px) { @@ -40,7 +40,7 @@ } .price-calc-section .card { - width: 50%; + /* width: 50%; */ margin: 0 auto; background: #fff; box-shadow: 1px 3px 6px 2px rgba(0, 0, 0, 0.2); @@ -52,7 +52,7 @@ @media (min-width: 768px) { .price-calc-section .card { - margin-left: 0; + /* margin-left: 0; */ } } diff --git a/hosting/static/hosting/js/initial.js b/hosting/static/hosting/js/initial.js index 1fca9735..35ecaadf 100644 --- a/hosting/static/hosting/js/initial.js +++ b/hosting/static/hosting/js/initial.js @@ -153,4 +153,84 @@ $( document ).ready(function() { $('.navbar-fixed-top.topnav').css('padding-right', topnavPadding-scrollbarWidth); } }); + + /* --------------------------------------------- + Scripts initialization + --------------------------------------------- */ + var cardPricing = { + 'cpu': { + 'id': 'coreValue', + 'value': 1, + 'min': 1, + 'max': 48, + 'interval': 1 + }, + 'ram': { + 'id': 'ramValue', + 'value': 2, + 'min': 1, + 'max': 200, + 'interval': 1 + }, + 'storage': { + 'id': 'storageValue', + 'value': 10, + 'min': 10, + 'max': 2000, + 'interval': 10 + } + }; + + function _initPricing() { + _fetchPricing(); + + $('.fa-minus-circle.left').click(function(event) { + var data = $(this).data('minus'); + + if (cardPricing[data].value > cardPricing[data].min) { + cardPricing[data].value = Number(cardPricing[data].value) - cardPricing[data].interval; + } + _fetchPricing(); + }); + $('.fa-plus-circle.right').click(function(event) { + var data = $(this).data('plus'); + if (cardPricing[data].value < cardPricing[data].max) { + cardPricing[data].value = Number(cardPricing[data].value) + cardPricing[data].interval; + } + _fetchPricing(); + }); + + $('.input-price').change(function() { + var data = $(this).attr("name"); + cardPricing[data].value = $('input[name=' + data + ']').val(); + _fetchPricing(); + }); + } + + function _fetchPricing() { + Object.keys(cardPricing).map(function(element) { + $('input[name=' + element + ']').val(cardPricing[element].value); + }); + _calcPricing(); + } + + function _calcPricing() { + 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; + } + console.log(coresUnitPrice, ramUnitPrice, ssdUnitPrice, cardPricing) + 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); + } + + _initPricing(); }); \ No newline at end of file diff --git a/hosting/templates/hosting/base_short.html b/hosting/templates/hosting/base_short.html index 9c1538db..63f2b499 100644 --- a/hosting/templates/hosting/base_short.html +++ b/hosting/templates/hosting/base_short.html @@ -1,5 +1,5 @@ -{% load staticfiles bootstrap3%} -{% load i18n %} +{% load staticfiles i18n cms_tags sekizai_tags %} + @@ -29,6 +29,9 @@ {% block css_extra %} {% endblock css_extra %} + {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} + {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %} + @@ -48,7 +51,7 @@ - + {% cms_toolbar %} {% block navbar %} {% include "hosting/includes/_navbar_user.html" %} diff --git a/hosting/templates/hosting/create_virtual_machine.html b/hosting/templates/hosting/create_virtual_machine.html index a614dd78..5c4bc3cf 100644 --- a/hosting/templates/hosting/create_virtual_machine.html +++ b/hosting/templates/hosting/create_virtual_machine.html @@ -1,7 +1,9 @@ {% extends "hosting/base_short.html" %} -{% load staticfiles bootstrap3 i18n %} +{% load staticfiles bootstrap3 i18n cms_tags %} {% block content %} + +
@@ -17,14 +19,8 @@ {% endif %}
-
-
-
-
- {% include "hosting/calculator_form.html" %} -
-
-
+
+ {% render_placeholder cms_integration.calculator_placeholder %}
diff --git a/hosting/views.py b/hosting/views.py index ec36836a..b288be3b 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -32,6 +32,7 @@ from stored_messages.settings import stored_messages_settings from datacenterlight.models import VMTemplate from datacenterlight.tasks import create_vm_task +from datacenterlight.utils import get_cms_integration from membership.models import CustomUser, StripeCustomer from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import ( @@ -1003,7 +1004,11 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): @method_decorator(decorators) def get(self, request, *args, **kwargs): - context = {'templates': VMTemplate.objects.all()} + print(get_cms_integration('default')) + context = { + 'templates': VMTemplate.objects.all(), + 'cms_integration': get_cms_integration('default'), + } return render(request, self.template_name, context) @method_decorator(decorators) From 3b3b73a2ce7278db39052e71f22bbbef98e87e2f Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 15:08:28 +0530 Subject: [PATCH 14/60] alignment calculator plugin --- 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 0096faa5..4c8be828 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -41,7 +41,7 @@ class DCLSectionPlugin(CMSPluginBase): print(child.__dict__) if child.__class__.__name__ in right_children: context['children_to_side'].append(child) - elif child.__class__.__name__ == 'CMSPlugin': + elif child.plugin_type == 'DCLCalculatorPlugin': context['children_calculator'].append(child) else: context['children_to_content'].append(child) From f66d768ecb3733612d1c9e2410a8d951a8a74c53 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 15:55:58 +0530 Subject: [PATCH 15/60] hosting payment page --- .../static/datacenterlight/js/main.js | 2 +- .../templates/datacenterlight/cms/base.html | 1 + .../includes/_calculator_form.html | 2 +- hosting/static/hosting/js/initial.js | 3 +- hosting/templates/hosting/payment.html | 5 ++- hosting/views.py | 44 ++++++++++++++----- 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js index 35f2b247..f6ba036b 100644 --- a/datacenterlight/static/datacenterlight/js/main.js +++ b/datacenterlight/static/datacenterlight/js/main.js @@ -175,7 +175,7 @@ window.coresUnitPrice = 5; } if(typeof window.ramUnitPrice === 'undefined'){ - window.coresUnitPrice = 2; + window.ramUnitPrice = 2; } if(typeof window.ssdUnitPrice === 'undefined'){ window.ssdUnitPrice = 0.6; diff --git a/datacenterlight/templates/datacenterlight/cms/base.html b/datacenterlight/templates/datacenterlight/cms/base.html index 942a0ad4..a614db67 100644 --- a/datacenterlight/templates/datacenterlight/cms/base.html +++ b/datacenterlight/templates/datacenterlight/cms/base.html @@ -61,6 +61,7 @@
{% endplaceholder %} + {% url 'datacenterlight:index' as calculator_form_url %} {% placeholder 'Datacenterlight Content' %} {% placeholder 'datacenterlight_footer'%} diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index 656e78e7..8335c7ec 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -11,7 +11,7 @@ {% endif %} -
+ {% csrf_token %}

{% trans "VM hosting" %}

diff --git a/hosting/static/hosting/js/initial.js b/hosting/static/hosting/js/initial.js index 35ecaadf..7159da9a 100644 --- a/hosting/static/hosting/js/initial.js +++ b/hosting/static/hosting/js/initial.js @@ -219,12 +219,11 @@ $( document ).ready(function() { window.coresUnitPrice = 5; } if(typeof window.ramUnitPrice === 'undefined'){ - window.coresUnitPrice = 2; + window.ramUnitPrice = 2; } if(typeof window.ssdUnitPrice === 'undefined'){ window.ssdUnitPrice = 0.6; } - console.log(coresUnitPrice, ramUnitPrice, ssdUnitPrice, cardPricing) var total = (cardPricing['cpu'].value * window.coresUnitPrice) + (cardPricing['ram'].value * window.ramUnitPrice) + (cardPricing['storage'].value * window.ssdUnitPrice); diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 4878831e..d6574bdf 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -42,12 +42,13 @@
+ {%trans "Total" %} {%trans "including VAT" %}
-
{{request.session.specs.price|intcomma}} - CHF/{% trans "Month" %} +
+ {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}
diff --git a/hosting/views.py b/hosting/views.py index b288be3b..63d99a91 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -30,7 +30,7 @@ from stored_messages.api import mark_read from stored_messages.models import Message from stored_messages.settings import stored_messages_settings -from datacenterlight.models import VMTemplate +from datacenterlight.models import VMTemplate, VMPricing from datacenterlight.tasks import create_vm_task from datacenterlight.utils import get_cms_integration from membership.models import CustomUser, StripeCustomer @@ -1020,18 +1020,34 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): storage = request.POST.get('storage') storage_field = forms.IntegerField(validators=[self.validate_storage]) template_id = int(request.POST.get('config')) + pricing_name = request.POST.get('pricing_name') + vm_pricing = VMPricing.get_vm_pricing_by_name(pricing_name) template = VMTemplate.objects.filter( opennebula_vm_template_id=template_id).first() template_data = VMTemplateSerializer(template).data + if vm_pricing is None: + vm_pricing_name_msg = _( + "Incorrect pricing name. Please contact support" + "{support_email}".format( + support_email=settings.DCL_SUPPORT_FROM_ADDRESS + ) + ) + messages.add_message( + self.request, messages.ERROR, vm_pricing_name_msg, + extra_tags='pricing' + ) + return redirect(CreateVirtualMachinesView.as_view()) + else: + vm_pricing_name = vm_pricing.name + try: cores = cores_field.clean(cores) except ValidationError as err: msg = '{} : {}.'.format(cores, str(err)) messages.add_message(self.request, messages.ERROR, msg, extra_tags='cores') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + return redirect(CreateVirtualMachinesView.as_view()) try: memory = memory_field.clean(memory) @@ -1039,8 +1055,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): msg = '{} : {}.'.format(memory, str(err)) messages.add_message(self.request, messages.ERROR, msg, extra_tags='memory') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") + return redirect(CreateVirtualMachinesView.as_view()) try: storage = storage_field.clean(storage) @@ -1048,15 +1063,24 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): msg = '{} : {}.'.format(storage, str(err)) messages.add_message(self.request, messages.ERROR, msg, extra_tags='storage') - return HttpResponseRedirect( - reverse('datacenterlight:index') + "#order_form") - price = get_vm_price(cpu=cores, memory=memory, - disk_size=storage) + return redirect(CreateVirtualMachinesView.as_view()) + + price, vat, vat_percent = get_vm_price_with_vat( + cpu=cores, + memory=memory, + ssd_size=storage, + pricing_name=vm_pricing_name + ) + specs = { 'cpu': cores, 'memory': memory, 'disk_size': storage, - 'price': price + 'price': price, + 'vat': vat, + 'vat_percent': vat_percent, + 'total_price': price + vat, + 'pricing_name': vm_pricing_name } request.session['specs'] = specs From 91a65e88ec35caa79885ac3726cf577a8149a687 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 16:08:05 +0530 Subject: [PATCH 16/60] hosting vm payment price fix --- hosting/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 63d99a91..d0d2a99c 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -855,7 +855,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, 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 14548b2f0158c3842bb68f422a8e6f394aa969e0 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 17:26:31 +0530 Subject: [PATCH 17/60] flake8 refacoring --- datacenterlight/cms_plugins.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 4c8be828..ecc0a355 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -1,4 +1,3 @@ -from cms.models.pluginmodel import CMSPlugin from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -9,7 +8,7 @@ from .cms_models import ( DCLSectionPluginModel, DCLNavbarPluginModel, DCLSectionPromoPluginModel, DCLCalculatorPluginModel ) -from .models import VMTemplate, VMPricing +from .models import VMTemplate @plugin_pool.register_plugin @@ -91,33 +90,9 @@ class DCLCalculatorPlugin(CMSPluginBase): context, instance, placeholder ) context['templates'] = VMTemplate.objects.all() - # pricing_plugin_model = None - # if instance.child_plugin_instances is not 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() 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 0c4c945ec3d3ad1ef640c305c9ff4d26157a9414 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 17:51:36 +0530 Subject: [PATCH 18/60] flake8 fix --- hosting/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index d0d2a99c..495efd5c 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -43,7 +43,7 @@ from utils.forms import ( BillingAddressForm, PasswordResetRequestForm, UserBillingAddressForm, ResendActivationEmailForm ) -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.mailer import BaseEmail from utils.stripe_utils import StripeUtils from utils.tasks import send_plain_email_task From 89ed869780b32c4515ed524042506aca512e1b23 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 25 Apr 2018 23:31:27 +0530 Subject: [PATCH 19/60] hosting calculator styles --- .../static/hosting/css/price_calculator.css | 23 +++++++++++-------- hosting/templates/hosting/payment.html | 3 +-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hosting/static/hosting/css/price_calculator.css b/hosting/static/hosting/css/price_calculator.css index 61fb277b..68961d33 100644 --- a/hosting/static/hosting/css/price_calculator.css +++ b/hosting/static/hosting/css/price_calculator.css @@ -2,6 +2,8 @@ .price-calc-section { padding: 20px 0 !important; + font-weight: 300; + font-size: 18px; } @media (max-width: 768px) { @@ -40,13 +42,13 @@ } .price-calc-section .card { - /* width: 50%; */ + border-radius: 7px; margin: 0 auto; background: #fff; box-shadow: 1px 3px 6px 2px rgba(0, 0, 0, 0.2); padding-bottom: 30px; text-align: center; - max-width: 320px; + max-width: 4000px; position: relative; } @@ -85,7 +87,7 @@ } .price-calc-section .card .description { - padding: 7px 8px 2px; + padding: 12px; position: relative; display: flex; justify-content: space-around !important; @@ -93,7 +95,7 @@ } .price-calc-section .card .description span { - font-size: 14px; + font-size: 16px; margin-left: 5px; /* margin-left: 0px; */ /* justify-self: start; */ @@ -104,17 +106,18 @@ } .price-calc-section .card .description .select-number{ - font-size: 16px; + font-size: 18px; text-align: center; width: 85px; + padding: 5px 10px; } .price-calc-section .card .description i { color: #29427a; cursor: pointer; font-size: 20px; - border: 1px solid #ccc; - padding: 5px 6px 3px; + /* border: 1px solid #ccc; */ + /* padding: 5px 6px 3px; */ border-radius: 5px; } @@ -193,7 +196,7 @@ .price-calc-section .help-block.with-errors { text-align: center; margin: 0 0; - padding: 0 0 5px; + padding: 0 0; } .price-calc-section .help-block.with-errors ul { margin-bottom: 0; @@ -209,10 +212,10 @@ display: block; position: absolute; bottom: 0; - left: 18%; + left: 0; z-index: 20; height: 1px; - width: 65%; + width: 100%; background: rgba(128, 128, 128, 0.2); } diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index d6574bdf..ab6c6a65 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -42,8 +42,7 @@
- - {%trans "Total" %} {%trans "including VAT" %} + {%trans "Total" %} {% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %}
From 34df86fb90fdfd2547d02fb0f71322f6f230dad9 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 28 Apr 2018 00:56:11 +0530 Subject: [PATCH 20/60] add favicon extension to ungleich_template --- .../templates/ungleich_page/ungleich_cms_page.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ungleich_page/templates/ungleich_page/ungleich_cms_page.html b/ungleich_page/templates/ungleich_page/ungleich_cms_page.html index f8d32f07..42293b04 100644 --- a/ungleich_page/templates/ungleich_page/ungleich_cms_page.html +++ b/ungleich_page/templates/ungleich_page/ungleich_cms_page.html @@ -33,7 +33,11 @@ {% include "google_analytics.html" %} - + {% if request.current_page.cmsfaviconextension %} + + {% else %} + + {% endif %} From 35fb872dc1ff5f143daa12f1d3434f235c4d577a Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 1 May 2018 00:00:05 +0530 Subject: [PATCH 21/60] Update Changelog --- Changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 86c21db0..e4558a9d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +1.7.2: 2018-04-30 + * bgfix: [cms] add favicon extension to ungleich cms pages + * #4474: [cms] reduce heading slider side padding 1.7.1: 2018-04-21 * #4481: [blog] fix de blog pages 500 error * #4370: [comic] new url /comic to show only comic blogs From d6db984156c2aa4c813c9799d02d369d1fe7948c Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 1 May 2018 00:48:31 +0530 Subject: [PATCH 22/60] Update ungleich.css --- ungleich_page/static/ungleich_page/css/ungleich.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ungleich_page/static/ungleich_page/css/ungleich.css b/ungleich_page/static/ungleich_page/css/ungleich.css index 2537a921..af71e692 100644 --- a/ungleich_page/static/ungleich_page/css/ungleich.css +++ b/ungleich_page/static/ungleich_page/css/ungleich.css @@ -195,7 +195,7 @@ flex: 1; } -.header_slider > .carousel .item .container { +.header_slider > .carousel .item .container-fluid { overflow: auto; padding: 50px 20px 60px; height: 100%; @@ -236,7 +236,7 @@ .header_slider .carousel-control .fa { font-size: 4em; } - .header_slider > .carousel .item .container { + .header_slider > .carousel .item .container-fluid { overflow: auto; padding: 75px 50px; } @@ -403,4 +403,4 @@ left: 0; bottom: 0; background: rgba(0,0,0,0.35); -} \ No newline at end of file +} From ccf55acbaf85561345ac9e50e93cdb3642f57146 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 1 May 2018 04:36:29 +0530 Subject: [PATCH 23/60] Update navbar_dropdown.html --- .../templates/datacenterlight/cms/navbar_dropdown.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/cms/navbar_dropdown.html b/datacenterlight/templates/datacenterlight/cms/navbar_dropdown.html index 051e8914..70926874 100644 --- a/datacenterlight/templates/datacenterlight/cms/navbar_dropdown.html +++ b/datacenterlight/templates/datacenterlight/cms/navbar_dropdown.html @@ -1,10 +1,10 @@ {% load cms_tags %} \ No newline at end of file +
From 4d2d337651c91857d65f587dc87042b238e330ce Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 1 May 2018 16:44:15 +0530 Subject: [PATCH 24/60] Release 1.8 --- Changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changelog b/Changelog index e4558a9d..2c2877ab 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +1.8: 2018-05-01 + * #4527: [hosting] cms calculator on non-cms pages for the hosting app + * bgfix: [dcl] navbar dropdown target fix + * bgfix: [hosting] login/signup pages footer link fix 1.7.2: 2018-04-30 * bgfix: [cms] add favicon extension to ungleich cms pages * #4474: [cms] reduce heading slider side padding From 25ef657c621c2a16a668e096c784663c1ac50915 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 1 May 2018 18:15:56 +0530 Subject: [PATCH 25/60] Update cms_plugins.py --- datacenterlight/cms_plugins.py | 1 - 1 file changed, 1 deletion(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index ecc0a355..12de0daf 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -37,7 +37,6 @@ class DCLSectionPlugin(CMSPluginBase): 'DCLSectionIconPluginModel', ] for child in instance.child_plugin_instances: - print(child.__dict__) if child.__class__.__name__ in right_children: context['children_to_side'].append(child) elif child.plugin_type == 'DCLCalculatorPlugin': From f8dc2c6bbee5a8a48c259bf55ef4c2b48a42b062 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 05:07:58 +0530 Subject: [PATCH 26/60] discount option added to calculator --- datacenterlight/cms_plugins.py | 1 - .../migrations/0022_auto_20180506_1950.py | 25 ++ datacenterlight/models.py | 12 +- .../static/datacenterlight/css/common.css | 9 + .../static/datacenterlight/js/main.js | 6 +- .../includes/_calculator_form.html | 11 +- .../datacenterlight/landing_payment.html | 19 +- .../datacenterlight/order_detail.html | 8 + datacenterlight/views.py | 5 +- hosting/static/hosting/css/commons.css | 9 + hosting/static/hosting/css/landing-page.css | 224 ------------ hosting/static/hosting/css/order.css | 4 + hosting/static/hosting/css/payment.css | 333 +++++++++++++----- hosting/static/hosting/js/initial.js | 6 +- hosting/templates/hosting/order_detail.html | 8 + hosting/templates/hosting/payment.html | 331 +++++++++-------- hosting/views.py | 8 +- utils/hosting_utils.py | 11 +- 18 files changed, 554 insertions(+), 476 deletions(-) create mode 100644 datacenterlight/migrations/0022_auto_20180506_1950.py diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index ecc0a355..12de0daf 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -37,7 +37,6 @@ class DCLSectionPlugin(CMSPluginBase): 'DCLSectionIconPluginModel', ] for child in instance.child_plugin_instances: - print(child.__dict__) if child.__class__.__name__ in right_children: context['children_to_side'].append(child) elif child.plugin_type == 'DCLCalculatorPlugin': diff --git a/datacenterlight/migrations/0022_auto_20180506_1950.py b/datacenterlight/migrations/0022_auto_20180506_1950.py new file mode 100644 index 00000000..dd79b825 --- /dev/null +++ b/datacenterlight/migrations/0022_auto_20180506_1950.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-05-06 14:20 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0021_cmsintegration_calculator_placeholder'), + ] + + operations = [ + migrations.AddField( + model_name='vmpricing', + name='discount_amount', + field=models.DecimalField(decimal_places=2, default=0, max_digits=4), + ), + migrations.AddField( + model_name='vmpricing', + name='discount_name', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/datacenterlight/models.py b/datacenterlight/models.py index eceb7617..56a19f03 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -34,6 +34,10 @@ class VMPricing(models.Model): hdd_unit_price = models.DecimalField( max_digits=7, decimal_places=6, default=0 ) + discount_name = models.CharField(max_length=255, null=True, blank=True) + discount_amount = models.DecimalField( + max_digits=4, decimal_places=2, default=0 + ) def __str__(self): return self.name + ' => ' + ' - '.join([ @@ -42,8 +46,12 @@ class VMPricing(models.Model): '{}/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', ] - ) + if not self.vat_inclusive else 'VAT-Incl', + '{} {}'.format( + self.discount_amount if self.discount_amount else '', + self.discount_name if self.discount_name else 'Discount' + ), + ]) @classmethod def get_vm_pricing_by_name(cls, name): diff --git a/datacenterlight/static/datacenterlight/css/common.css b/datacenterlight/static/datacenterlight/css/common.css index 895256ef..b6eabd75 100644 --- a/datacenterlight/static/datacenterlight/css/common.css +++ b/datacenterlight/static/datacenterlight/css/common.css @@ -150,3 +150,12 @@ footer .dcl-link-separator::before { border-radius: 100%; background: #777; } + +.mb-0 { + margin-bottom: 0; +} + +.thin-hr { + margin-top: 10px; + margin-bottom: 10px; +} \ No newline at end of file diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js index f6ba036b..292e8c16 100644 --- a/datacenterlight/static/datacenterlight/js/main.js +++ b/datacenterlight/static/datacenterlight/js/main.js @@ -180,9 +180,13 @@ if(typeof window.ssdUnitPrice === 'undefined'){ window.ssdUnitPrice = 0.6; } + if(typeof window.discountAmount === 'undefined'){ + window.discountAmount = 0; + } var total = (cardPricing['cpu'].value * window.coresUnitPrice) + (cardPricing['ram'].value * window.ramUnitPrice) + - (cardPricing['storage'].value * window.ssdUnitPrice); + (cardPricing['storage'].value * window.ssdUnitPrice) - + window.discountAmount; total = parseFloat(total.toFixed(2)); $("#total").text(total); } diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index 8335c7ec..dfc0bf22 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -8,6 +8,7 @@ window.ramUnitPrice = {{vm_pricing.ram_unit_price|default:0}}; window.ssdUnitPrice = {{vm_pricing.ssd_unit_price|default:0}}; window.hddUnitPrice = {{vm_pricing.hdd_unit_price|default:0}}; + window.discountAmount = {{vm_pricing.discount_amount|default:0}}; {% endif %} @@ -19,11 +20,15 @@
CHF/{% trans "month" %} - {% if vm_pricing.vat_inclusive %}
-

{% trans "VAT included" %}

+

+ {% if vm_pricing.vat_inclusive %}{% trans "VAT included" %}
{% endif %} + {% if vm_pricing.discount_amount %} + {% trans "Discount" as discount_name %} + {{ vm_pricing.discount_amount }} CHF {{ vm_pricing.discount_name|default:discount_name }} included + {% endif %} +

- {% endif %}
diff --git a/datacenterlight/templates/datacenterlight/landing_payment.html b/datacenterlight/templates/datacenterlight/landing_payment.html index b808e033..4d111fa1 100644 --- a/datacenterlight/templates/datacenterlight/landing_payment.html +++ b/datacenterlight/templates/datacenterlight/landing_payment.html @@ -78,7 +78,24 @@

{% trans "Configuration"%} {{request.session.template.name}}


-

{%trans "Total" %}  ({% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %}) {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}

+

+ {%trans "Total" %}   + + ({% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %}) + + {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %} +

+
+ {% if vm_pricing.discount_amount %} +

+ {%trans "Discount" as discount_name %} + {{ vm_pricing.discount_name|default:discount_name }}   + - {{ vm_pricing.discount_amount }} CHF/{% trans "Month" %} +

+

+ ({% trans "Will be applied at checkout" %}) +

+ {% endif %}
diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 95bfa3c6..13d2c61e 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -65,6 +65,7 @@ {% trans "Disk space" %}: {{vm.disk_size|intcomma}} GB

+
{% if vm.vat > 0 %}

{% trans "Subtotal" %}: @@ -75,6 +76,13 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} + {% if vm_pricing.discount_amount %} +

+ {%trans "Discount" as discount_name %} + {{ vm_pricing.discount_name|default:discount_name }}: + - {{ vm_pricing.discount_amount }} CHF +

+ {% endif %}

{% trans "Total" %} {{vm.total_price|floatformat:2|intcomma}} CHF diff --git a/datacenterlight/views.py b/datacenterlight/views.py index cccd4277..bc5ea49e 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -387,7 +387,10 @@ class OrderConfirmationView(DetailView): 'billing_address_data': ( request.session.get('billing_address_data') ), - 'cms_integration': get_cms_integration('default') + 'cms_integration': get_cms_integration('default'), + 'vm_pricing': VMPricing.get_vm_pricing_by_name( + self.request.session['specs']['pricing_name'] + ), } return render(request, self.template_name, context) diff --git a/hosting/static/hosting/css/commons.css b/hosting/static/hosting/css/commons.css index 59ca56eb..0abfd499 100644 --- a/hosting/static/hosting/css/commons.css +++ b/hosting/static/hosting/css/commons.css @@ -361,4 +361,13 @@ .locale_date.done{ opacity: 1; +} + +.mb-0 { + margin-bottom: 0; +} + +.thin-hr { + margin-top: 10px; + margin-bottom: 10px; } \ No newline at end of file diff --git a/hosting/static/hosting/css/landing-page.css b/hosting/static/hosting/css/landing-page.css index d5236324..389e6999 100644 --- a/hosting/static/hosting/css/landing-page.css +++ b/hosting/static/hosting/css/landing-page.css @@ -449,230 +449,6 @@ a.unlink:hover { color: inherit; } -/***** DCL payment page **********/ -.dcl-order-container { - font-weight: 300; -} - -.dcl-order-table-header { - border-bottom: 1px solid #eee; - padding-top: 15px; - padding-bottom: 15px; - font-size: 16px; - color: #333; - text-align: center; - font-weight: 300; -} - -.dcl-order-table-content { - border-bottom: 1px solid #eee; - padding-top: 15px; - padding-bottom: 15px; - font-size: 18px; - font-weight: 600; - text-align: center; -} - -.tbl-content { -} - -.dcl-order-table-total { - border-bottom: 4px solid #eee; - padding-top: 15px; - padding-bottom: 20px; - font-size: 20px; - font-weight: 600; - color: #999; -} - -.dcl-order-table-total span { - font-size: 13px; - color: #999; - font-weight: 400; - padding-left: 5px; -} - -.dcl-place-order-text{ - color: #808080; -} - -.dcl-order-table-total .tbl-total { - text-align: center; - color: #000; - padding-left: 44px; -} - -.tbl-total .dcl-price-month { - font-size: 16px; - text-transform: capitalize; - color: #000; -} - -.tbl-no-padding { - padding: 0px; -} - -.dcl-billing-sec { - margin-top: 50px; -} - -.dcl-order-sec { - padding: 0 30px; -} - -.card-warning-content { - font-weight: 300; - border: 1px solid #a1a1a1; - border-radius: 3px; - padding: 5px; - margin-bottom: 15px; -} -.card-warning-error { - border: 1px solid #EB4D5C; - color: #EB4D5C; -} - -.card-warning-addtional-margin { - margin-top: 15px; -} - -.stripe-payment-btn { - outline: none; - width: auto; - float: right; - font-style: normal; - font-weight: 300; - position: absolute; - padding-left: 30px; - padding-right: 30px; - right: 0; -} - -.card-cvc-element label { - padding-left: 10px; -} - -.card-element { - margin-bottom: 10px; -} - -.card-element label{ - width:100%; - margin-bottom:0px; -} - -.my-input { - border-bottom: 1px solid #ccc; - } - -.card-cvc-element .my-input { - padding-left: 10px; -} - -#card-errors { - clear: both; - padding: 0 0 10px; - color: #eb4d5c; -} - -.credit-card-goup{ - padding: 0; -} - -@media (max-width: 767px) { - .dcl-order-table-total span { - padding-left: 3px; - } - - .dcl-order-sec { - padding: 10px 20px 30px 20px; - border-bottom: 4px solid #eee; - } - - .tbl-header { - border-bottom: 1px solid #eee; - padding: 10px 0; - } - - .tbl-content { - border-bottom: 1px solid #eee; - padding: 10px 0; - } - - .dcl-order-table-header { - border-bottom: 0px solid #eee; - padding: 10px 0; - text-align: left; - } - - .dcl-order-table-content { - border-bottom: 0px solid #eee; - padding: 10px 0; - text-align: right; - font-size: 16px; - } - - .dcl-order-table-total { - font-size: 18px; - color: #000; - padding: 10px 0; - border-bottom: 0px solid #eee; - } - - .dcl-order-table-total .tbl-total { - padding: 0px; - text-align: right; - } - - .dcl-billing-sec { - margin-top: 30px; - margin-bottom: 30px; - } - - .card-expiry-element { - padding-right: 10px; - } - - .card-cvc-element { - padding-left: 10px; - } - - #billing-form .form-control { - box-shadow: none !important; - font-weight: 400; - } -} - -@media (min-width: 1200px) { - .dcl-order-container { - width: 990px; - padding-right: 15px; - padding-left: 15px; - margin-right: auto; - margin-left: auto; - } -} - -@media (min-width: 768px) { - .dcl-billing { - padding-right: 65px; - border-right: 1px solid #eee; - } - - .dcl-creditcard { - padding-left: 65px; - } - - .tbl-tot { - padding-left: 17px; - } - - .content-dashboard { - /*width: auto !important;*/ - } - -} - @media only screen and (max-width: 1040px) and (min-width: 768px) { .content-dashboard { width: 96% !important; diff --git a/hosting/static/hosting/css/order.css b/hosting/static/hosting/css/order.css index 0cd22c21..27a67f3e 100644 --- a/hosting/static/hosting/css/order.css +++ b/hosting/static/hosting/css/order.css @@ -96,4 +96,8 @@ #virtual_machine_create_form { padding: 15px 0; +} + +.dcl-place-order-text { + color: #808080; } \ No newline at end of file diff --git a/hosting/static/hosting/css/payment.css b/hosting/static/hosting/css/payment.css index de89afd0..8a1bc70f 100644 --- a/hosting/static/hosting/css/payment.css +++ b/hosting/static/hosting/css/payment.css @@ -1,19 +1,35 @@ - -.payment-container {padding-top:70px; padding-bottom: 11%;} -.creditcard-box .panel-title {display: inline;font-weight: bold; font-size:17px;} -.creditcard-box .checkbox.pull-right { margin: 0; } -.creditcard-box .pl-ziro { padding-left: 0px; } -.creditcard-box .form-control.error { - border-color: red; - outline: 0; - box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(255,0,0,0.6); +.payment-container { + padding-top: 70px; + padding-bottom: 11%; } + +.creditcard-box .panel-title { + display: inline; + font-weight: bold; + font-size: 17px; +} + +.creditcard-box .checkbox.pull-right { + margin: 0; +} + +.creditcard-box .pl-ziro { + padding-left: 0px; +} + +.creditcard-box .form-control.error { + border-color: red; + outline: 0; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6); +} + .creditcard-box label.error { font-weight: bold; color: red; padding: 2px 8px; margin-top: 2px; } + .creditcard-box .payment-errors { font-weight: bold; color: red; @@ -21,96 +37,221 @@ margin-top: 2px; } -/* landing page payment new style */ -.last-p { - margin-bottom: 0; -} -.dcl-payment-section { - max-width: 391px; - margin: 0 auto 30px; - padding: 0 10px 30px; - border-bottom: 1px solid #edebeb; - height: 100%; -} -.dcl-payment-section hr{ - margin-top: 15px; - margin-bottom: 15px; -} -.dcl-payment-section .top-hr { - margin-left: -10px; -} -.dcl-payment-section h3 { - font-weight: 600; -} -.dcl-payment-section p { - /*padding: 0 5px;*/ - font-weight: 400; -} -.dcl-payment-section .card-warning-content { - padding: 8px 10px; - font-weight: 300; -} -.dcl-payment-order strong{ - font-size: 17px; -} -.dcl-payment-order p { - font-weight: 300; -} -.dcl-payment-section .form-group { - margin-bottom: 10px; -} -.dcl-payment-section .form-control { - box-shadow: none; - padding: 6px 12px; - height: 32px; -} -.dcl-payment-user { - height: 100%; - display: flex; - flex-direction: column; - justify-content: center; +.dcl-order-sec { + padding: 0 30px; } -.dcl-payment-user h4 { - font-weight: 600; - font-size: 17px; +.dcl-billing-sec { + margin-top: 50px; +} + +.dcl-order-container { + font-weight: 300; +} + +.dcl-order-table-header { + border-bottom: 1px solid #eee; + padding: 15px 10px; + font-size: 16px; + color: #333; + font-weight: 300; +} + +.dcl-order-table-content { + border-bottom: 1px solid #eee; + padding: 15px 10px; + font-size: 18px; + font-weight: 600; +} + +.dcl-order-table-total { + border-bottom: 4px solid #eee; + padding-top: 15px; + padding-bottom: 20px; + font-size: 20px; + font-weight: 600; +} + +.dcl-order-table-total span { + font-size: 13px; + color: #999; + font-weight: 400; +} + +.dcl-order-table-total .tbl-total { + text-align: right; + color: #000; +} + +.tbl-no-padding { + padding: 0px; +} + +.card-warning-content { + font-weight: 300; + border: 1px solid #a1a1a1; + border-radius: 3px; + padding: 5px; + margin-bottom: 15px; +} + +.card-warning-error { + border: 1px solid #EB4D5C; + color: #EB4D5C; +} + +.card-warning-addtional-margin { + margin-top: 15px; +} + +.stripe-payment-btn { + outline: none; + width: auto; + float: right; + font-style: normal; + font-weight: 300; + position: absolute; + padding-left: 30px; + padding-right: 30px; + right: 0; +} + +.card-cvc-element label { + padding-left: 10px; +} + +.card-element { + margin-bottom: 10px; +} + +.card-element label { + width: 100%; + margin-bottom: 0px; +} + +.my-input { + border-bottom: 1px solid #ccc; +} + +.card-cvc-element .my-input { + padding-left: 10px; +} + +#card-errors { + clear: both; + padding: 0 0 10px; + color: #eb4d5c; +} + +.credit-card-goup { + padding: 0; +} + +@media (max-width: 767px) { + .dcl-order-sec { + padding: 10px 5px 30px; + border-bottom: 4px solid #eee; + } + + .dcl-billing-sec { + margin-top: 30px; + margin-bottom: 30px; + padding: 5px; + } + + .dcl-billing { + margin-top: 20px; + margin-bottom: 40px; + } + + .tbl-header { + border-bottom: 1px solid #eee; + padding-top: 10px; + padding-bottom: 10px; + margin-right: -15px; + } + + .dcl-order-table-total .tbl-total { + margin-left: -15px; + } + + .dcl-order-table-total .tbl-tot { + margin-right: -15px; + } + + .tbl-content { + border-bottom: 1px solid #eee; + padding-top: 10px; + padding-bottom: 10px; + margin-left: -15px; + } + + .dcl-order-table-header { + border-bottom: 0px solid #eee; + padding: 10px 0; + text-align: left; + } + + .dcl-order-table-content { + border-bottom: 0px solid #eee; + padding: 10px 0; + text-align: right; + font-size: 16px; + } + + .dcl-order-table-total { + font-size: 18px; + color: #000; + padding: 10px 0; + border-bottom: 0px solid #eee; + } + + .card-expiry-element { + padding-right: 10px; + } + + .card-cvc-element { + padding-left: 10px; + } + + #billing-form .form-control { + box-shadow: none !important; + font-weight: 400; + } } @media (min-width: 768px) { - .dcl-payment-grid { - display: flex; - align-items: stretch; - flex-wrap: wrap; - } - .dcl-payment-box { - width: 50%; - position: relative; - padding: 0 30px; - } - .dcl-payment-box:nth-child(2) { - order: 1; - } - .dcl-payment-box:nth-child(4) { - order: 2; - } - .dcl-payment-section { - padding: 15px 10px; - margin-bottom: 0; - border-bottom-width: 5px; - } - .dcl-payment-box:nth-child(2n) .dcl-payment-section { - border-bottom: none; - } - .dcl-payment-box:nth-child(1):after, - .dcl-payment-box:nth-child(2):after { - content: ' '; - display: block; - background: #eee; - width: 1px; - position: absolute; - right: 0; - z-index: 2; - top: 20px; - bottom: 20px; - } + .dcl-billing { + padding-right: 65px; + border-right: 1px solid #eee; + } + + .dcl-creditcard { + padding-left: 65px; + } + + .dcl-order-table-total .tbl-total, + .dcl-order-table-total .tbl-tot { + padding: 0 10px; + } + + .tbl-header-center, + .tbl-content-center { + text-align: center; + } + + .tbl-header-right, + .tbl-content-right { + text-align: right; + } } + +@media (min-width: 1200px) { + .dcl-order-container { + width: 990px; + padding-right: 15px; + padding-left: 15px; + margin-right: auto; + margin-left: auto; + } +} \ No newline at end of file diff --git a/hosting/static/hosting/js/initial.js b/hosting/static/hosting/js/initial.js index 7159da9a..9c1c226e 100644 --- a/hosting/static/hosting/js/initial.js +++ b/hosting/static/hosting/js/initial.js @@ -224,9 +224,13 @@ $( document ).ready(function() { if(typeof window.ssdUnitPrice === 'undefined'){ window.ssdUnitPrice = 0.6; } + if(typeof window.discountAmount === 'undefined'){ + window.discountAmount = 0; + } var total = (cardPricing['cpu'].value * window.coresUnitPrice) + (cardPricing['ram'].value * window.ramUnitPrice) + - (cardPricing['storage'].value * window.ssdUnitPrice); + (cardPricing['storage'].value * window.ssdUnitPrice) - + window.discountAmount; total = parseFloat(total.toFixed(2)); $("#total").text(total); } diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 2568aafc..ec50528d 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -127,6 +127,7 @@ {% trans "Disk space" %}: {{vm.disk_size}} GB

+
{% if vm.vat > 0 %}

{% trans "Subtotal" %}: @@ -137,6 +138,13 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} + {% if vm_pricing.discount_amount %} +

+ {%trans "Discount" as discount_name %} + {{ vm_pricing.discount_name|default:discount_name }}: + - {{ vm_pricing.discount_amount }} CHF +

+ {% endif %}

{% trans "Total" %} {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index ab6c6a65..afcf6373 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -9,159 +9,208 @@

-
-
-

{%trans "Your Order" %}

-
-
- {%trans "Cores" %} -
-
- {%trans "Memory" %} -
-
- {%trans "Disk space" %} -
-
- {%trans "Configuration" %} +
+

{%trans "Your Order" %}

+
+
+
+
+
+
+ {%trans "Cores" %} +
+
+
+
+ {%trans "Memory" %} +
+
+
+
+ {%trans "Disk space" %} +
+
+
+
+ {%trans "Configuration" %} +
+
+
-
-
- {{request.session.specs.cpu|floatformat}} -
-
- {{request.session.specs.memory|floatformat}} GB -
-
- {{request.session.specs.disk_size|floatformat|intcomma}} GB -
-
- {{request.session.template.name}} -
-
-
-
- {%trans "Total" %} {% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %} -
-
-
-
- {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %} +
+
+
+
+
+ {{request.session.specs.cpu|floatformat}} +
+
+
+
+ {{request.session.specs.memory|floatformat}} GB +
+
+
+
+ {{request.session.specs.disk_size|floatformat|intcomma}} GB +
+
+
+
+ {{request.session.template.name}} +
+
-
-
-
-
-

{%trans "Billing Address"%}

-
- - {% for field in form %} - {% csrf_token %} - {% bootstrap_field field show_label=False type='fields'%} - {% endfor %} - +
+
+
+
+ {%trans "Total" %}  + {% if vm_pricing.vat_inclusive %}{%trans "including VAT" %}{% else %}{%trans "excluding VAT" %}{% endif %} +
+
+
+
+ {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %} +
+
-
-

{%trans "Credit Card"%}

-
-
-

- {% blocktrans %}Please fill in your credit card information below. We are using Stripe for payment and do not store your information in our database.{% endblocktrans %} -

+ {% if vm_pricing.discount_amount %} +
+
+
+
+ {%trans "Discount" as discount_name %} + {{ vm_pricing.discount_name|default:discount_name }}  
+ ({% trans "Will be applied at checkout" %}) +
+
+
+
+
- {{ vm_pricing.discount_amount }} CHF/{% trans "Month" %}
+
+
+
+ {% endif %} +
+
+
+
+
+
+

{%trans "Billing Address"%}

+
+
+ {% for field in form %} + {% csrf_token %} + {% bootstrap_field field show_label=False type='fields'%} + {% endfor %} +
+
+
+
+
+

{%trans "Credit Card"%}

+
- {% if credit_card_data.last4 %} -
-
Credit Card
-
Last 4: *****{{credit_card_data.last4}}
-
Type: {{credit_card_data.cc_brand}}
- -
- {% if not messages and not form.non_field_errors %} -

- {% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %} -

- {% endif %} -
- {% for message in messages %} - {% if 'failed_payment' or 'make_charge_error' in message.tags %} -
    -
  • -

    {{ message|safe }}

    -
  • -
- {% endif %} - {% endfor %} - {% for error in form.non_field_errors %} -

- {{ error|escape }} +

+ {% blocktrans %}Please fill in your credit card information below. We are using Stripe for payment and do not store your information in our database.{% endblocktrans %} +

+
+ {% if credit_card_data.last4 %} +
+
Credit Card
+
Last 4: *****{{credit_card_data.last4}}
+
Type: {{credit_card_data.cc_brand}}
+ +
+ {% if not messages and not form.non_field_errors %} +

+ {% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %}

- {% endfor %} -
-
- -
- {% else %} -
- -
-
-
- -
-
-
-
- -
-
-
- -
-
-
-
- - -
-
-
-
- {% if not messages and not form.non_field_errors %} -

- {% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %} + {% endif %} +

+ {% for message in messages %} + {% if 'failed_payment' or 'make_charge_error' in message.tags %} +
    +
  • +

    {{ message|safe }}

    +
  • +
+ {% endif %} + {% endfor %} + {% for error in form.non_field_errors %} +

+ {{ error|escape }}

- {% endif %} -
- {% for message in messages %} - {% if 'failed_payment' or 'make_charge_error' in message.tags %} -
    -
  • -

    {{ message|safe }}

    -
  • -
- {% endif %} - {% endfor %} - - {% for error in form.non_field_errors %} -

- {{ error|escape }} + {% endfor %} +

+
+ +
+ {% else %} + + +
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ + +
+
+
+
+ {% if not messages and not form.non_field_errors %} +

+ {% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %}

- {% endfor %} -
-
- -
-
+ {% endif %} +
+ {% for message in messages %} + {% if 'failed_payment' or 'make_charge_error' in message.tags %} +
    +
  • +

    {{ message|safe }}

    +
  • +
+ {% endif %} + {% endfor %} -
-

-
- - {% endif %} + {% for error in form.non_field_errors %} +

+ {{ error|escape }} +

+ {% endfor %} +
+
+ +
+
+ +
+

+
+ + {% endif %} +
diff --git a/hosting/views.py b/hosting/views.py index 495efd5c..1353229a 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -652,7 +652,10 @@ class PaymentVMView(LoginRequiredMixin, FormView): }) context.update({ - 'stripe_key': settings.STRIPE_API_PUBLIC_KEY + 'stripe_key': settings.STRIPE_API_PUBLIC_KEY, + 'vm_pricing': VMPricing.get_vm_pricing_by_name( + self.request.session['specs']['pricing_name'] + ) }) return context @@ -806,6 +809,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['cc_brand'] = card_details.get('response_object').get( 'cc_brand') context['vm'] = self.request.session.get('specs') + context['vm_pricing'] = VMPricing.get_vm_pricing_by_name( + self.request.session['specs']['pricing_name'] + ), return context @method_decorator(decorators) diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index 04ed658a..b6e267a2 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -107,10 +107,13 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, ) return None - 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)) + 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) - + pricing.discount_amount + ) if pricing.vat_inclusive: vat = decimal.Decimal(0) vat_percent = decimal.Decimal(0) From 7a72cc02abc9db3dc7d13322f2e5bafd8bc48fca Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 05:22:05 +0530 Subject: [PATCH 27/60] translations --- .../locale/de/LC_MESSAGES/django.po | 12 +++++++- dynamicweb/settings/base.py | 4 +++ hosting/locale/de/LC_MESSAGES/django.po | 28 +++++++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po index 50dbfbe8..cd92b339 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-17 19:26+0000\n" +"POT-Creation-Date: 2018-05-07 05:15+0530\n" "PO-Revision-Date: 2018-03-30 23:22+0000\n" "Last-Translator: b'Anonymous User '\n" "Language-Team: LANGUAGE \n" @@ -19,6 +19,9 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Translated-Using: django-rosetta 0.8.1\n" +msgid "CMS Favicon" +msgstr "" + #, python-format msgid "Your New VM %(vm_name)s at Data Center Light" msgstr "Deine neue VM %(vm_name)s bei Data Center Light" @@ -140,6 +143,9 @@ msgstr "Monat" msgid "VAT included" msgstr "MwSt. inklusive" +msgid "Discount" +msgstr "Rabatt" + msgid "Hosted in Switzerland" msgstr "Standort: Schweiz" @@ -314,6 +320,9 @@ msgstr "exkl. Mehrwertsteuer" msgid "Month" msgstr "Monat" +msgid "Will be applied at checkout" +msgstr "wird an der Kasse angewendet" + msgid "Credit Card" msgstr "Kreditkarte" @@ -386,6 +395,7 @@ 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" diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index da3f0941..f540e998 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -267,6 +267,10 @@ LANGUAGES = ( LANGUAGE_CODE = 'en-us' +LOCALE_PATHS = [ + os.path.join(PROJECT_DIR, 'digitalglarus/locale'), +] + CMS_PLACEHOLDER_CONF = { 'logo_image': { 'name': 'Logo Image', diff --git a/hosting/locale/de/LC_MESSAGES/django.po b/hosting/locale/de/LC_MESSAGES/django.po index 118245e5..42e46314 100644 --- a/hosting/locale/de/LC_MESSAGES/django.po +++ b/hosting/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: 2017-12-21 00:23+0000\n" +"POT-Creation-Date: 2018-05-07 05:15+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -365,13 +365,25 @@ msgstr "Arbeitsspeicher" msgid "Disk space" msgstr "Festplattenkapazität" +msgid "Subtotal" +msgstr "Zwischensumme" + +msgid "VAT" +msgstr "Mehrwertsteuer" + +msgid "Discount" +msgstr "Rabatt" + msgid "Total" msgstr "Gesamt" -#, python-format +#, fuzzy, python-format +#| msgid "" +#| "By clicking \"Place order\" this plan will charge your credit card " +#| "account with the fee of %(vm_price)sCHF/month" 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_price|intcomma)sCHF/month" msgstr "" "Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_price)sCHF " "pro Monat belastet" @@ -421,6 +433,12 @@ msgstr "Konfiguration" msgid "including VAT" msgstr "inkl. Mehrwertsteuer" +msgid "excluding VAT" +msgstr "exkl. Mehrwertsteuer" + +msgid "Will be applied at checkout" +msgstr "wird an der Kasse angewendet" + msgid "Billing Address" msgstr "Rechnungsadresse" @@ -699,6 +717,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 "" "We could not find the requested VM. Please " "contact Data Center Light Support." From 2ff8c250340e8710958711c441894e2e11f5c371 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 06:11:44 +0530 Subject: [PATCH 28/60] exclude discount from total price --- datacenterlight/models.py | 17 +++++++++++------ .../datacenterlight/order_detail.html | 2 +- datacenterlight/views.py | 8 +++----- hosting/views.py | 19 +++++++++---------- utils/hosting_utils.py | 6 +++--- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/datacenterlight/models.py b/datacenterlight/models.py index 56a19f03..ff7eeb8d 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -36,22 +36,27 @@ class VMPricing(models.Model): ) discount_name = models.CharField(max_length=255, null=True, blank=True) discount_amount = models.DecimalField( - max_digits=4, decimal_places=2, default=0 + max_digits=6, decimal_places=2, default=0 ) def __str__(self): - return self.name + ' => ' + ' - '.join([ + display_str = 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', - '{} {}'.format( - self.discount_amount if self.discount_amount else '', - self.discount_name if self.discount_name else 'Discount' - ), ]) + if self.discount_amount: + display_str = ' - '.join([ + display_str, + '{} {}'.format( + self.discount_amount, + self.discount_name if self.discount_name else 'Discount' + ) + ]) + return display_str @classmethod def get_vm_pricing_by_name(cls, name): diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 13d2c61e..3b269377 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -76,7 +76,7 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} - {% if vm_pricing.discount_amount %} + {% if vm.discount > 0 %}

{%trans "Discount" as discount_name %} {{ vm_pricing.discount_name|default:discount_name }}: diff --git a/datacenterlight/views.py b/datacenterlight/views.py index bc5ea49e..8f4c886f 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -158,7 +158,7 @@ class IndexView(CreateView): ) return HttpResponseRedirect(referer_url + "#order_form") - price, vat, vat_percent = get_vm_price_with_vat( + price, vat, vat_percent, discount = get_vm_price_with_vat( cpu=cores, memory=memory, ssd_size=storage, @@ -171,7 +171,8 @@ class IndexView(CreateView): 'price': price, 'vat': vat, 'vat_percent': vat_percent, - 'total_price': price + vat, + 'discount': discount, + 'total_price': price + vat - discount, 'pricing_name': vm_pricing_name } request.session['specs'] = specs @@ -388,9 +389,6 @@ class OrderConfirmationView(DetailView): request.session.get('billing_address_data') ), 'cms_integration': get_cms_integration('default'), - 'vm_pricing': VMPricing.get_vm_pricing_by_name( - self.request.session['specs']['pricing_name'] - ), } return render(request, self.template_name, context) diff --git a/hosting/views.py b/hosting/views.py index 1353229a..99897841 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -655,7 +655,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): 'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'vm_pricing': VMPricing.get_vm_pricing_by_name( self.request.session['specs']['pricing_name'] - ) + ), }) return context @@ -753,7 +753,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['vm'] = vm_detail.__dict__ context['vm']['name'] = '{}-{}'.format( context['vm']['configuration'], context['vm']['vm_id']) - price, vat, vat_percent = get_vm_price_with_vat( + price, vat, vat_percent, discount = get_vm_price_with_vat( cpu=context['vm']['cores'], ssd_size=context['vm']['disk_size'], memory=context['vm']['memory'], @@ -762,8 +762,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): ) context['vm']['vat'] = vat context['vm']['price'] = price + context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent - context['vm']['total_price'] = price + vat + context['vm']['total_price'] = price + vat - discount context['subscription_end_date'] = vm_detail.end_date() except VMDetail.DoesNotExist: try: @@ -772,7 +773,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): ) vm = manager.get_vm(obj.vm_id) context['vm'] = VirtualMachineSerializer(vm).data - price, vat, vat_percent = get_vm_price_with_vat( + price, vat, vat_percent, discount = get_vm_price_with_vat( cpu=context['vm']['cores'], ssd_size=context['vm']['disk_size'], memory=context['vm']['memory'], @@ -781,8 +782,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): ) context['vm']['vat'] = vat context['vm']['price'] = price + context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent - context['vm']['total_price'] = price + vat + context['vm']['total_price'] = price + vat - discount except WrongIdError: messages.error( self.request, @@ -809,9 +811,6 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['cc_brand'] = card_details.get('response_object').get( 'cc_brand') context['vm'] = self.request.session.get('specs') - context['vm_pricing'] = VMPricing.get_vm_pricing_by_name( - self.request.session['specs']['pricing_name'] - ), return context @method_decorator(decorators) @@ -1071,7 +1070,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): extra_tags='storage') return redirect(CreateVirtualMachinesView.as_view()) - price, vat, vat_percent = get_vm_price_with_vat( + price, vat, vat_percent, discount = get_vm_price_with_vat( cpu=cores, memory=memory, ssd_size=storage, @@ -1085,7 +1084,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): 'price': price, 'vat': vat, 'vat_percent': vat_percent, - 'total_price': price + vat, + 'total_price': price + vat - discount, 'pricing_name': vm_pricing_name } diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index b6e267a2..9e96634f 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -111,8 +111,7 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, (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) - - pricing.discount_amount + (decimal.Decimal(hdd_size) * pricing.hdd_unit_price) ) if pricing.vat_inclusive: vat = decimal.Decimal(0) @@ -124,4 +123,5 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, 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), float(vat_percent) + discount = pricing.discount_amount + return float(price), float(vat), float(vat_percent), float(discount) From eeed9b2e7214aacd2e1e3152de3d5628434083fb Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 06:25:50 +0530 Subject: [PATCH 29/60] discount name in templates --- .../templates/datacenterlight/order_detail.html | 4 ++-- datacenterlight/views.py | 2 +- hosting/templates/hosting/order_detail.html | 6 +++--- hosting/views.py | 7 ++++--- utils/hosting_utils.py | 7 +++++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 3b269377..1bedbb44 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -79,8 +79,8 @@ {% if vm.discount > 0 %}

{%trans "Discount" as discount_name %} - {{ vm_pricing.discount_name|default:discount_name }}: - - {{ vm_pricing.discount_amount }} CHF + {{ vm.discount.name|default:discount_name }}: + - {{ discount.amount }} CHF

{% endif %}

diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 8f4c886f..79411fbb 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -172,7 +172,7 @@ class IndexView(CreateView): 'vat': vat, 'vat_percent': vat_percent, 'discount': discount, - 'total_price': price + vat - discount, + 'total_price': price + vat - discount.amount, 'pricing_name': vm_pricing_name } request.session['specs'] = specs diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index ec50528d..1ed75bd9 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -138,11 +138,11 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} - {% if vm_pricing.discount_amount %} + {% if vm.discount > 0 %}

{%trans "Discount" as discount_name %} - {{ vm_pricing.discount_name|default:discount_name }}: - - {{ vm_pricing.discount_amount }} CHF + {{ vm.discount.name|default:discount_name }}: + - {{ discount.amount }} CHF

{% endif %}

diff --git a/hosting/views.py b/hosting/views.py index 99897841..7b3cc357 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -764,7 +764,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['vm']['price'] = price context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent - context['vm']['total_price'] = price + vat - discount + context['vm']['total_price'] = price + vat - discount.amount context['subscription_end_date'] = vm_detail.end_date() except VMDetail.DoesNotExist: try: @@ -784,7 +784,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['vm']['price'] = price context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent - context['vm']['total_price'] = price + vat - discount + context['vm']['total_price'] = price + \ + vat - discount.amount except WrongIdError: messages.error( self.request, @@ -1084,7 +1085,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): 'price': price, 'vat': vat, 'vat_percent': vat_percent, - 'total_price': price + vat - discount, + 'total_price': price + vat - discount.amount, 'pricing_name': vm_pricing_name } diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index 9e96634f..36964867 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -123,5 +123,8 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, cents = decimal.Decimal('.01') price = price.quantize(cents, decimal.ROUND_HALF_UP) vat = vat.quantize(cents, decimal.ROUND_HALF_UP) - discount = pricing.discount_amount - return float(price), float(vat), float(vat_percent), float(discount) + discount = { + 'name': pricing.discount_name, + 'amount': float(pricing.discount_amount), + } + return float(price), float(vat), float(vat_percent), discount From 3d2ce279548809c1de71ab6b13d4fdb343a20931 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 06:29:53 +0530 Subject: [PATCH 30/60] fix discount amount --- datacenterlight/views.py | 2 +- hosting/views.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 79411fbb..ec10a341 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -172,7 +172,7 @@ class IndexView(CreateView): 'vat': vat, 'vat_percent': vat_percent, 'discount': discount, - 'total_price': price + vat - discount.amount, + 'total_price': price + vat - discount['amount'], 'pricing_name': vm_pricing_name } request.session['specs'] = specs diff --git a/hosting/views.py b/hosting/views.py index 7b3cc357..ec583a9b 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -764,7 +764,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['vm']['price'] = price context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent - context['vm']['total_price'] = price + vat - discount.amount + context['vm']['total_price'] = price + vat - discount['amount'] context['subscription_end_date'] = vm_detail.end_date() except VMDetail.DoesNotExist: try: @@ -785,7 +785,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView): context['vm']['discount'] = discount context['vm']['vat_percent'] = vat_percent context['vm']['total_price'] = price + \ - vat - discount.amount + vat - discount['amount'] except WrongIdError: messages.error( self.request, @@ -1085,7 +1085,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): 'price': price, 'vat': vat, 'vat_percent': vat_percent, - 'total_price': price + vat - discount.amount, + 'total_price': price + vat - discount['amount'], 'pricing_name': vm_pricing_name } From 0fdb88b8aa5659dafdd709f81edffb95bb7c4e80 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 07:50:32 +0530 Subject: [PATCH 31/60] invoice discount amount fix --- datacenterlight/migrations/0022_auto_20180506_1950.py | 5 +++-- datacenterlight/templates/datacenterlight/order_detail.html | 4 ++-- hosting/templates/hosting/order_detail.html | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/datacenterlight/migrations/0022_auto_20180506_1950.py b/datacenterlight/migrations/0022_auto_20180506_1950.py index dd79b825..a5554a58 100644 --- a/datacenterlight/migrations/0022_auto_20180506_1950.py +++ b/datacenterlight/migrations/0022_auto_20180506_1950.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-05-06 14:20 +# Generated by Django 1.9.4 on 2018-05-07 02:19 from __future__ import unicode_literals from django.db import migrations, models @@ -15,7 +15,8 @@ class Migration(migrations.Migration): migrations.AddField( model_name='vmpricing', name='discount_amount', - field=models.DecimalField(decimal_places=2, default=0, max_digits=4), + field=models.DecimalField( + decimal_places=2, default=0, max_digits=6), ), migrations.AddField( model_name='vmpricing', diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 1bedbb44..fbe7ff0f 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -76,11 +76,11 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} - {% if vm.discount > 0 %} + {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} {{ vm.discount.name|default:discount_name }}: - - {{ discount.amount }} CHF + - {{ vm.discount.amount }} CHF

{% endif %}

diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 1ed75bd9..11aa3474 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -138,11 +138,11 @@ {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} - {% if vm.discount > 0 %} + {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} {{ vm.discount.name|default:discount_name }}: - - {{ discount.amount }} CHF + - {{ vm.discount.amount }} CHF

{% endif %}

From 55cbe3244a4625558804f491ea296ce26b48d3ff Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Mon, 7 May 2018 09:14:31 +0530 Subject: [PATCH 32/60] fix testing error --- hosting/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index ec583a9b..7623ed90 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -654,7 +654,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): context.update({ 'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'vm_pricing': VMPricing.get_vm_pricing_by_name( - self.request.session['specs']['pricing_name'] + self.request.session.get('specs', {}).get('pricing_name') ), }) @@ -1010,7 +1010,6 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): @method_decorator(decorators) def get(self, request, *args, **kwargs): - print(get_cms_integration('default')) context = { 'templates': VMTemplate.objects.all(), 'cms_integration': get_cms_integration('default'), From b351cb9aa04d6d9f1f3675c3c99646144660cf75 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 10 May 2018 21:25:38 +0530 Subject: [PATCH 33/60] translation fix --- hosting/locale/de/LC_MESSAGES/django.po | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hosting/locale/de/LC_MESSAGES/django.po b/hosting/locale/de/LC_MESSAGES/django.po index 42e46314..1404b594 100644 --- a/hosting/locale/de/LC_MESSAGES/django.po +++ b/hosting/locale/de/LC_MESSAGES/django.po @@ -377,10 +377,7 @@ msgstr "Rabatt" msgid "Total" msgstr "Gesamt" -#, fuzzy, python-format -#| msgid "" -#| "By clicking \"Place order\" this plan will charge your credit card " -#| "account with the fee of %(vm_price)sCHF/month" +#, python-format msgid "" "By clicking \"Place order\" this plan will charge your credit card account " "with the fee of %(vm_price|intcomma)sCHF/month" From f3ffbd96e5d1d31b60d51e378c4c9e23188bdcef Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 10 May 2018 21:26:47 +0530 Subject: [PATCH 34/60] translation fix --- hosting/locale/de/LC_MESSAGES/django.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/locale/de/LC_MESSAGES/django.po b/hosting/locale/de/LC_MESSAGES/django.po index 1404b594..b981d408 100644 --- a/hosting/locale/de/LC_MESSAGES/django.po +++ b/hosting/locale/de/LC_MESSAGES/django.po @@ -382,7 +382,7 @@ msgid "" "By clicking \"Place order\" this plan will charge your credit card account " "with the fee of %(vm_price|intcomma)sCHF/month" msgstr "" -"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_price)sCHF " +"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_price|intcomma)sCHF " "pro Monat belastet" msgid "Place order" From 73e3dce8d495196005359aa8cb2880595cb2152f Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 11 May 2018 17:18:19 +0530 Subject: [PATCH 35/60] order detail page font format --- .../static/datacenterlight/css/hosting.css | 2 +- .../templates/datacenterlight/order_detail.html | 12 ++++++------ hosting/static/hosting/css/order.css | 2 +- hosting/templates/hosting/order_detail.html | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/datacenterlight/static/datacenterlight/css/hosting.css b/datacenterlight/static/datacenterlight/css/hosting.css index b4c5909c..87c40329 100644 --- a/datacenterlight/static/datacenterlight/css/hosting.css +++ b/datacenterlight/static/datacenterlight/css/hosting.css @@ -482,6 +482,7 @@ margin: 100px auto 40px; border: 1px solid #ccc; padding: 30px 30px 20px; + color: #595959; } .order-detail-container .dashboard-title-thin { @@ -515,7 +516,6 @@ .order-detail-container p { margin-bottom: 5px; - color: #595959; } .order-detail-container hr { diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index fbe7ff0f..4b52d4d5 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -59,33 +59,33 @@

{% trans "Memory" %}: - {{vm.memory|intcomma}} GB + {{vm.memory|intcomma}} GB

{% trans "Disk space" %}: - {{vm.disk_size|intcomma}} GB + {{vm.disk_size|intcomma}} GB


{% if vm.vat > 0 %}

{% trans "Subtotal" %}: - {{vm.price|floatformat:2|intcomma}} CHF + {{vm.price|floatformat:2|intcomma}} CHF

{% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%): - {{vm.vat|floatformat:2|intcomma}} CHF + {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} {{ vm.discount.name|default:discount_name }}: - - {{ vm.discount.amount }} CHF + - {{ vm.discount.amount }} CHF

{% endif %}

{% trans "Total" %} - {{vm.total_price|floatformat:2|intcomma}} CHF + {{vm.total_price|floatformat:2|intcomma}} CHF

diff --git a/hosting/static/hosting/css/order.css b/hosting/static/hosting/css/order.css index 27a67f3e..5d39f24b 100644 --- a/hosting/static/hosting/css/order.css +++ b/hosting/static/hosting/css/order.css @@ -3,6 +3,7 @@ margin: 100px auto 40px; border: 1px solid #ccc; padding: 15px; + color: #595959; } @media(min-width: 768px) { @@ -60,7 +61,6 @@ .order-detail-container p { margin-bottom: 5px; - color: #595959; } .order-detail-container hr { diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 11aa3474..d08a7151 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -114,40 +114,40 @@

{% trans "Cores" %}: {% if vm.cores %} - {{vm.cores|floatformat}} + {{vm.cores|floatformat}} {% else %} - {{vm.cpu|floatformat}} + {{vm.cpu|floatformat}} {% endif %}

{% trans "Memory" %}: - {{vm.memory}} GB + {{vm.memory}} GB

{% trans "Disk space" %}: - {{vm.disk_size}} GB + {{vm.disk_size}} GB


{% if vm.vat > 0 %}

{% trans "Subtotal" %}: - {{vm.price|floatformat:2|intcomma}} CHF + {{vm.price|floatformat:2|intcomma}} CHF

{% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%): - {{vm.vat|floatformat:2|intcomma}} CHF + {{vm.vat|floatformat:2|intcomma}} CHF

{% endif %} {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} {{ vm.discount.name|default:discount_name }}: - - {{ vm.discount.amount }} CHF + - {{ vm.discount.amount }} CHF

{% endif %}

{% trans "Total" %} - {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF + {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF

From a14407182ff3983859b43e05bcc5fc790a42773c Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 11 May 2018 17:21:02 +0530 Subject: [PATCH 36/60] font weight for discount name --- datacenterlight/templates/datacenterlight/order_detail.html | 4 ++-- hosting/templates/hosting/order_detail.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 4b52d4d5..dfa6634e 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -55,7 +55,7 @@

{% trans "Cores" %}: - {{vm.cpu|floatformat}} + {{vm.cpu|floatformat}}

{% trans "Memory" %}: @@ -79,7 +79,7 @@ {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} - {{ vm.discount.name|default:discount_name }}: + {{ vm.discount.name|default:discount_name }}: - {{ vm.discount.amount }} CHF

{% endif %} diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index d08a7151..9dea5359 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -141,7 +141,7 @@ {% if vm.discount.amount > 0 %}

{%trans "Discount" as discount_name %} - {{ vm.discount.name|default:discount_name }}: + {{ vm.discount.name|default:discount_name }}: - {{ vm.discount.amount }} CHF

{% endif %} From 30deae5a201ec75ad0e7047d8e9949e2cfde142a Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 11 May 2018 17:25:44 +0530 Subject: [PATCH 37/60] strong color fix --- datacenterlight/static/datacenterlight/css/hosting.css | 4 ---- hosting/static/hosting/css/order.css | 4 ---- 2 files changed, 8 deletions(-) diff --git a/datacenterlight/static/datacenterlight/css/hosting.css b/datacenterlight/static/datacenterlight/css/hosting.css index 87c40329..047f4922 100644 --- a/datacenterlight/static/datacenterlight/css/hosting.css +++ b/datacenterlight/static/datacenterlight/css/hosting.css @@ -504,10 +504,6 @@ margin-bottom: 15px; } -.order-detail-container .order-details strong { - color: #595959; -} - .order-detail-container h4 { font-size: 16px; font-weight: bold; diff --git a/hosting/static/hosting/css/order.css b/hosting/static/hosting/css/order.css index 5d39f24b..fa932798 100644 --- a/hosting/static/hosting/css/order.css +++ b/hosting/static/hosting/css/order.css @@ -49,10 +49,6 @@ margin-bottom: 15px; } -.order-detail-container .order-details strong { - color: #595959; -} - .order-detail-container h4 { font-size: 16px; font-weight: bold; From 8044e0c2a0f30c057d1ed69d61b2410e3e608c38 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 11 May 2018 17:47:27 +0530 Subject: [PATCH 38/60] calculator discount text modified --- .../templates/datacenterlight/includes/_calculator_form.html | 3 +-- hosting/views.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html index dfc0bf22..4b4aa04f 100644 --- a/datacenterlight/templates/datacenterlight/includes/_calculator_form.html +++ b/datacenterlight/templates/datacenterlight/includes/_calculator_form.html @@ -24,8 +24,7 @@

{% if vm_pricing.vat_inclusive %}{% trans "VAT included" %}
{% endif %} {% if vm_pricing.discount_amount %} - {% trans "Discount" as discount_name %} - {{ vm_pricing.discount_amount }} CHF {{ vm_pricing.discount_name|default:discount_name }} included + You save {{ vm_pricing.discount_amount }} CHF {% endif %}

diff --git a/hosting/views.py b/hosting/views.py index 7623ed90..8a4defda 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1081,6 +1081,7 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View): 'cpu': cores, 'memory': memory, 'disk_size': storage, + 'discount': discount, 'price': price, 'vat': vat, 'vat_percent': vat_percent, From 55889499df0527fd1ae957352a5b7a782b03b0f8 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 12 May 2018 02:47:27 +0530 Subject: [PATCH 39/60] order detail style fix --- .../static/datacenterlight/css/hosting.css | 16 +++++++ .../datacenterlight/order_detail.html | 45 ++++++++++--------- hosting/static/hosting/css/order.css | 16 +++++++ hosting/templates/hosting/order_detail.html | 45 ++++++++++--------- 4 files changed, 82 insertions(+), 40 deletions(-) diff --git a/datacenterlight/static/datacenterlight/css/hosting.css b/datacenterlight/static/datacenterlight/css/hosting.css index 047f4922..0f16ab77 100644 --- a/datacenterlight/static/datacenterlight/css/hosting.css +++ b/datacenterlight/static/datacenterlight/css/hosting.css @@ -518,6 +518,22 @@ margin: 15px 0; } +.order-detail-container .thin-hr { + margin: 10px 0; +} + +.order-detail-container .subtotal-price { + font-size: 16px; +} + +.order-detail-container .subtotal-price .text-primary { + font-size: 17px; +} + +.order-detail-container .total-price { + font-size: 18px; +} + @media (max-width: 767px) { .order-detail-container { padding: 15px; diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index dfa6634e..5515435a 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -65,32 +65,37 @@ {% trans "Disk space" %}: {{vm.disk_size|intcomma}} GB

-
- {% if vm.vat > 0 %} -

- {% trans "Subtotal" %}: - {{vm.price|floatformat:2|intcomma}} CHF -

-

- {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%): - {{vm.vat|floatformat:2|intcomma}} CHF -

+
+ {% if vm.vat > 0 or vm.discount.amount > 0 %} +
+ {% if vm.vat > 0 %} +

+ {% trans "Subtotal" %} + {{vm.price|floatformat:2|intcomma}} CHF +

+

+ {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%) + {{vm.vat|floatformat:2|intcomma}} CHF +

+ {% endif %} + {% if vm.discount.amount > 0 %} +

+ {%trans "Discount" as discount_name %} + {{ vm.discount.name|default:discount_name }} + - {{ vm.discount.amount }} CHF +

+ {% endif %} +
+
{% endif %} - {% if vm.discount.amount > 0 %} -

- {%trans "Discount" as discount_name %} - {{ vm.discount.name|default:discount_name }}: - - {{ vm.discount.amount }} CHF -

- {% endif %} -

- {% trans "Total" %} +

+ {% trans "Total" %} {{vm.total_price|floatformat:2|intcomma}} CHF

-
+
{% csrf_token %} diff --git a/hosting/static/hosting/css/order.css b/hosting/static/hosting/css/order.css index fa932798..8aafb8a8 100644 --- a/hosting/static/hosting/css/order.css +++ b/hosting/static/hosting/css/order.css @@ -63,6 +63,22 @@ margin: 15px 0; } +.order-detail-container .thin-hr { + margin: 10px 0; +} + +.order-detail-container .subtotal-price { + font-size: 16px; +} + +.order-detail-container .subtotal-price .text-primary { + font-size: 17px; +} + +.order-detail-container .total-price { + font-size: 18px; +} + @media (max-width: 767px) { .order-confirm-btn { text-align: center; diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 9dea5359..d84ed3d3 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -127,32 +127,37 @@ {% trans "Disk space" %}: {{vm.disk_size}} GB

-
- {% if vm.vat > 0 %} -

- {% trans "Subtotal" %}: - {{vm.price|floatformat:2|intcomma}} CHF -

-

- {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%): - {{vm.vat|floatformat:2|intcomma}} CHF -

+
+ {% if vm.vat > 0 or vm.discount.amount > 0 %} +
+ {% if vm.vat > 0 %} +

+ {% trans "Subtotal" %} + {{vm.price|floatformat:2|intcomma}} CHF +

+

+ {% trans "VAT" %} ({{ vm.vat_percent|floatformat:2|intcomma }}%) + {{vm.vat|floatformat:2|intcomma}} CHF +

+ {% endif %} + {% if vm.discount.amount > 0 %} +

+ {%trans "Discount" as discount_name %} + {{ vm.discount.name|default:discount_name }} + - {{ vm.discount.amount }} CHF +

+ {% endif %} +
+
{% endif %} - {% if vm.discount.amount > 0 %} -

- {%trans "Discount" as discount_name %} - {{ vm.discount.name|default:discount_name }}: - - {{ vm.discount.amount }} CHF -

- {% endif %} -

- {% trans "Total" %} +

+ {% trans "Total" %} {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF

-
+
{% if not order %} {% block submit_btn %} From 39f7898259b2ff627103bf8f69bf9b18426a2f3c Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 12 May 2018 03:15:07 +0530 Subject: [PATCH 40/60] edit order detail footer text --- datacenterlight/locale/de/LC_MESSAGES/django.po | 10 +++++----- .../templates/datacenterlight/order_detail.html | 2 +- hosting/locale/de/LC_MESSAGES/django.po | 8 ++++---- hosting/templates/hosting/order_detail.html | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/datacenterlight/locale/de/LC_MESSAGES/django.po b/datacenterlight/locale/de/LC_MESSAGES/django.po index cd92b339..9ac4f59a 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-05-07 05:15+0530\n" +"POT-Creation-Date: 2018-05-12 03:12+0530\n" "PO-Revision-Date: 2018-03-30 23:22+0000\n" "Last-Translator: b'Anonymous User '\n" "Language-Team: LANGUAGE \n" @@ -143,9 +143,6 @@ msgstr "Monat" msgid "VAT included" msgstr "MwSt. inklusive" -msgid "Discount" -msgstr "Rabatt" - msgid "Hosted in Switzerland" msgstr "Standort: Schweiz" @@ -320,6 +317,9 @@ msgstr "exkl. Mehrwertsteuer" msgid "Month" msgstr "Monat" +msgid "Discount" +msgstr "Rabatt" + msgid "Will be applied at checkout" msgstr "wird an der Kasse angewendet" @@ -398,7 +398,7 @@ 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" +"with %(vm_total_price)s CHF/month" msgstr "" "Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit " "%(vm_total_price)s CHF pro Monat belastet" diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 5515435a..8480e132 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -101,7 +101,7 @@ {% csrf_token %}
-
{% 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 %}.
+
{% blocktrans with vm_total_price=vm.total_price|floatformat:2|intcomma %}By clicking "Place order" this plan will charge your credit card account with {{vm_total_price}} CHF/month{% endblocktrans %}.
From 8fb0d9a48acdaf1b9607d1cdb5bb510171da6f1b Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Sat, 12 May 2018 21:59:06 +0530 Subject: [PATCH 45/60] order detail divider lines full width --- .../templates/datacenterlight/order_detail.html | 12 ++++++++++-- hosting/templates/hosting/order_detail.html | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 8480e132..49347ba2 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -65,8 +65,12 @@ {% trans "Disk space" %}: {{vm.disk_size|intcomma}} GB

+
+

- {% if vm.vat > 0 or vm.discount.amount > 0 %} +
+ {% if vm.vat > 0 or vm.discount.amount > 0 %} +
{% if vm.vat > 0 %}

@@ -86,8 +90,12 @@

{% endif %}
+
+

- {% endif %} +
+ {% endif %} +

{% 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 7def5b49..e2e38c35 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -127,8 +127,12 @@ {% trans "Disk space" %}: {{vm.disk_size}} GB

+
+

- {% if vm.vat > 0 or vm.discount.amount > 0 %} +
+ {% if vm.vat > 0 or vm.discount.amount > 0 %} +
{% if vm.vat > 0 %}

@@ -148,8 +152,12 @@

{% endif %}
+
+

- {% endif %} +
+ {% endif %} +

{% trans "Total" %} {% if vm.total_price %}{{vm.total_price|floatformat:2|intcomma}}{% else %}{{vm.price|floatformat:2|intcomma}}{% endif %} CHF From cba53e0fe3966331eee18611a7363f190d3c3319 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 17 May 2018 01:01:50 +0530 Subject: [PATCH 46/60] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 2c2877ab..8146462d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +1.9: 2018-05-16 + * #4559: [cms] enable discount on cms calculator 1.8: 2018-05-01 * #4527: [hosting] cms calculator on non-cms pages for the hosting app * bgfix: [dcl] navbar dropdown target fix From a4ca17e2edfdb30fb2bdba8d277d6ff0837119f9 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 24 May 2018 03:57:01 +0530 Subject: [PATCH 47/60] vm template prefix --- datacenterlight/admin.py | 3 ++- datacenterlight/cms_models.py | 6 ++++- datacenterlight/cms_plugins.py | 4 ++- .../migrations/0023_auto_20180524_0349.py | 25 +++++++++++++++++++ datacenterlight/models.py | 20 +++++++++++++-- opennebula_api/models.py | 10 ++++---- 6 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 datacenterlight/migrations/0023_auto_20180524_0349.py diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py index d95e4f87..5a1fc8a2 100644 --- a/datacenterlight/admin.py +++ b/datacenterlight/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from cms.admin.placeholderadmin import PlaceholderAdminMixin from cms.extensions import PageExtensionAdmin from .cms_models import CMSIntegration, CMSFaviconExtension -from .models import VMPricing +from .models import VMPricing, VMTemplate class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin): @@ -16,3 +16,4 @@ class CMSFaviconExtensionAdmin(PageExtensionAdmin): admin.site.register(CMSIntegration, CMSIntegrationAdmin) admin.site.register(CMSFaviconExtension, CMSFaviconExtensionAdmin) admin.site.register(VMPricing) +admin.site.register(VMTemplate) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 5a8d7ac8..e1703aaa 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -9,7 +9,7 @@ from djangocms_text_ckeditor.fields import HTMLField from filer.fields.file import FilerFileField from filer.fields.image import FilerImageField -from datacenterlight.models import VMPricing +from datacenterlight.models import VMPricing, VMTemplate class CMSIntegration(models.Model): @@ -299,3 +299,7 @@ class DCLCalculatorPluginModel(CMSPlugin): help_text='Choose a pricing that will be associated with this ' 'Calculator' ) + vm_type = models.CharField( + max_length=50, choices=VMTemplate.VM_TYPE_CHOICES, + default=VMTemplate.PUBLIC + ) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 12de0daf..769824e0 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -88,7 +88,9 @@ class DCLCalculatorPlugin(CMSPluginBase): context = super(DCLCalculatorPlugin, self).render( context, instance, placeholder ) - context['templates'] = VMTemplate.objects.all() + context['templates'] = VMTemplate.objects.filter( + vm_type=instance.vm_type + ) return context diff --git a/datacenterlight/migrations/0023_auto_20180524_0349.py b/datacenterlight/migrations/0023_auto_20180524_0349.py new file mode 100644 index 00000000..f37d6634 --- /dev/null +++ b/datacenterlight/migrations/0023_auto_20180524_0349.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-05-23 22:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0022_auto_20180506_1950'), + ] + + operations = [ + migrations.AddField( + model_name='dclcalculatorpluginmodel', + name='vm_type', + field=models.CharField(choices=[('public', 'Public'), ('ipv6only', 'Ipv6Only')], default='public', max_length=50), + ), + migrations.AddField( + model_name='vmtemplate', + name='vm_type', + field=models.CharField(choices=[('public', 'Public'), ('ipv6only', 'Ipv6Only')], default='public', max_length=50), + ), + ] diff --git a/datacenterlight/models.py b/datacenterlight/models.py index ff7eeb8d..729bbdf9 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -6,13 +6,29 @@ logger = logging.getLogger(__name__) class VMTemplate(models.Model): + PUBLIC = 'public' + IPV6 = 'ipv6only' + VM_TYPE_CHOICES = ( + (PUBLIC, PUBLIC.title()), + (IPV6, IPV6.title()), + ) name = models.CharField(max_length=50) opennebula_vm_template_id = models.IntegerField() + vm_type = models.CharField( + max_length=50, choices=VM_TYPE_CHOICES, default=PUBLIC + ) + + def __str__(self): + return '%s - %s - %s' % ( + self.opennebula_vm_template_id, self.vm_type, self.name + ) @classmethod - def create(cls, name, opennebula_vm_template_id): + def create(cls, name, opennebula_vm_template_id, vm_type): vm_template = cls( - name=name, opennebula_vm_template_id=opennebula_vm_template_id) + name=name, opennebula_vm_template_id=opennebula_vm_template_id, + vm_type=vm_type + ) return vm_template diff --git a/opennebula_api/models.py b/opennebula_api/models.py index d9b0b6c2..35f3d8e8 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -61,7 +61,7 @@ class OpenNebulaManager(): domain=settings.OPENNEBULA_DOMAIN, port=settings.OPENNEBULA_PORT, endpoint=settings.OPENNEBULA_ENDPOINT - )) + )) def _get_opennebula_client(self, username, password): return oca.Client("{0}:{1}".format( @@ -73,7 +73,7 @@ class OpenNebulaManager(): domain=settings.OPENNEBULA_DOMAIN, port=settings.OPENNEBULA_PORT, endpoint=settings.OPENNEBULA_ENDPOINT - )) + )) def _get_user(self, user): """Get the corresponding opennebula user for a CustomUser object @@ -362,12 +362,12 @@ class OpenNebulaManager(): except: raise ConnectionRefusedError - def get_templates(self): + def get_templates(self, prefix='public-'): try: public_templates = [ template for template in self._get_template_pool() - if template.name.startswith('public-') + if template.name.startswith(prefix) ] return public_templates except ConnectionRefusedError: @@ -439,7 +439,7 @@ class OpenNebulaManager(): def delete_template(self, template_id): self.oneadmin_client.call(oca.VmTemplate.METHODS[ - 'delete'], template_id, False) + 'delete'], template_id, False) def change_user_password(self, passwd_hash): self.oneadmin_client.call( From 2d1805f11d3426858cbd8f00eb526ed2183a6794 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 24 May 2018 04:14:53 +0530 Subject: [PATCH 48/60] update fetchvmtemplates command --- .../management/commands/fetchvmtemplates.py | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/datacenterlight/management/commands/fetchvmtemplates.py b/datacenterlight/management/commands/fetchvmtemplates.py index 6a45ebad..89271dc4 100644 --- a/datacenterlight/management/commands/fetchvmtemplates.py +++ b/datacenterlight/management/commands/fetchvmtemplates.py @@ -10,16 +10,28 @@ class Command(BaseCommand): help = '''Fetches the VM templates from OpenNebula and populates the dcl VMTemplate model''' + def get_templates(self, manager, prefix): + templates = manager.get_templates('%s-' % prefix) + dcl_vm_templates = [] + for template in templates: + template_name = template.name.lstrip('%s-' % prefix) + template_id = template.id + dcl_vm_template = VMTemplate.create( + template_name, template_id, prefix + ) + dcl_vm_templates.append(dcl_vm_template) + return dcl_vm_templates + def handle(self, *args, **options): try: manager = OpenNebulaManager() - templates = manager.get_templates() dcl_vm_templates = [] - for template in templates: - template_name = template.name.lstrip('public-') - template_id = template.id - dcl_vm_template = VMTemplate.create(template_name, template_id) - dcl_vm_templates.append(dcl_vm_template) + dcl_vm_templates.extend( + self.get_templates(manager, VMTemplate.PUBLIC) + ) + dcl_vm_templates.extend( + self.get_templates(manager, VMTemplate.IPV6) + ) old_vm_templates = VMTemplate.objects.all() old_vm_templates.delete() From 5748eecedb665675ae62b4bf5eb33dc55209c52f Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 13 Jun 2018 11:16:49 +0200 Subject: [PATCH 49/60] Create field for storing os_templates_to_show --- datacenterlight/models.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/datacenterlight/models.py b/datacenterlight/models.py index 729bbdf9..3801465a 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -1,5 +1,7 @@ import logging +from django import forms +from django.contrib.postgres.fields import ArrayField from django.db import models logger = logging.getLogger(__name__) @@ -32,7 +34,31 @@ class VMTemplate(models.Model): return vm_template +class MultipleChoiceArrayField(ArrayField): + """ + A field that allows us to store an array of choices. + Uses Django's Postgres ArrayField + and a MultipleChoiceField for its formfield. + """ + + def formfield(self, **kwargs): + defaults = { + 'form_class': forms.MultipleChoiceField, + 'choices': self.base_field.choices, + 'initial': [c[0] for c in self.base_field.choices], + } + defaults.update(kwargs) + # Skip our parent's formfield implementation completely as we don't + # care for it. + # pylint:disable=bad-super-call + return super(ArrayField, self).formfield(**defaults) + + class VMPricing(models.Model): + VMTemplateChoices = list( + (str(obj.opennebula_vm_template_id), obj.name) + for obj in VMTemplate.objects.all() + ) name = models.CharField(max_length=255, unique=True) vat_inclusive = models.BooleanField(default=True) vat_percentage = models.DecimalField( @@ -55,6 +81,18 @@ class VMPricing(models.Model): max_digits=6, decimal_places=2, default=0 ) + vm_templates_to_show = MultipleChoiceArrayField( + base_field=models.CharField( + blank=True, + max_length=256, + choices=VMTemplateChoices + ), + default=list, + blank=True, + help_text="Not selecting any items above will result in showing all " + "templates" + ) + def __str__(self): display_str = self.name + ' => ' + ' - '.join([ '{}/Core'.format(self.cores_unit_price.normalize()), From 94f520be355754a9164014f2569cf248441f4337 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 13 Jun 2018 11:17:18 +0200 Subject: [PATCH 50/60] Add migration --- .../0024_vmpricing_vm_templates_to_show.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py diff --git a/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py b/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py new file mode 100644 index 00000000..5705df5b --- /dev/null +++ b/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-06-13 09:09 +from __future__ import unicode_literals + +import datacenterlight.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0023_auto_20180524_0349'), + ] + + operations = [ + migrations.AddField( + model_name='vmpricing', + name='vm_templates_to_show', + field=datacenterlight.models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, choices=[('4', 'CentOS 7'), ('14', 'Debian 8'), ('25', 'Ubuntu 14.04'), ('26', 'Ubuntu 16.04'), ('36', 'Devuan Jessie'), ('65', 'Devuan Ascii'), ('69', 'FreeBSD 11.1')], max_length=256), blank=True, default=list, help_text='Not selecting any items above will result in showing all templates', size=None), + ), + ] From b872777bda964c36dd65073f03650db25e9a977c Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 13 Jun 2018 11:53:43 +0200 Subject: [PATCH 51/60] Filter context templates also by the ids that have been set for the calculator --- datacenterlight/cms_plugins.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 769824e0..9c6279bc 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -88,9 +88,15 @@ class DCLCalculatorPlugin(CMSPluginBase): context = super(DCLCalculatorPlugin, self).render( context, instance, placeholder ) - context['templates'] = VMTemplate.objects.filter( - vm_type=instance.vm_type - ) + ids = instance.pricing.vm_templates_to_show + if ids: + context['templates'] = VMTemplate.objects.filter( + vm_type=instance.vm_type + ).filter(opennebula_vm_template_id__in=ids) + else: + context['templates'] = VMTemplate.objects.filter( + vm_type=instance.vm_type + ) return context From dcbb0c2d64bb217e96a2921c115e8048d8f2b3c7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 19 Jun 2018 08:49:21 +0200 Subject: [PATCH 52/60] Add google analytics code for comic.ungleich.ch --- dynamicweb/settings/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index f540e998..75dfaa73 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -630,6 +630,7 @@ GOOGLE_ANALYTICS_PROPERTY_IDS = { 'ipv6onlyhosting.ch': 'UA-62285904-10', 'ipv6onlyhosting.net': 'UA-62285904-10', 'ipv6onlyhosting.com': 'UA-62285904-10', + 'comic.ungleich.ch': 'UA-62285904-13', '127.0.0.1:8000': 'localhost', 'dynamicweb-development.ungleich.ch': 'development', 'dynamicweb-staging.ungleich.ch': 'staging' From 79e83b4480e731b1ac8730227a2c691f74fe4b27 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 09:08:22 +0200 Subject: [PATCH 53/60] Refactor show_vm_templates to DCLCalculatorPluginModel from VMPricing --- datacenterlight/cms_models.py | 45 +++++++++++++++++++ datacenterlight/cms_plugins.py | 2 +- ...culatorpluginmodel_vm_templates_to_show.py | 21 +++++++++ .../0024_vmpricing_vm_templates_to_show.py | 21 --------- datacenterlight/models.py | 38 ---------------- 5 files changed, 67 insertions(+), 60 deletions(-) create mode 100644 datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py delete mode 100644 datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index e1703aaa..deb84dc7 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -2,6 +2,8 @@ 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 import forms +from django.contrib.postgres.fields import ArrayField from django.contrib.sites.models import Site from django.db import models from django.utils.safestring import mark_safe @@ -292,7 +294,35 @@ class DCLSectionPromoPluginModel(CMSPlugin): return extra_classes +class MultipleChoiceArrayField(ArrayField): + """ + A field that allows us to store an array of choices. + Uses Django's Postgres ArrayField + and a MultipleChoiceField for its formfield. + """ + + def formfield(self, **kwargs): + defaults = { + 'form_class': forms.MultipleChoiceField, + 'choices': self.base_field.choices, + } + defaults.update(kwargs) + # Skip our parent's formfield implementation completely as we don't + # care for it. + # pylint:disable=bad-super-call + return super(ArrayField, self).formfield(**defaults) + + class DCLCalculatorPluginModel(CMSPlugin): + VMTemplateChoices = list( + ( + str(obj.opennebula_vm_template_id), + (obj.name + ' - ' + VMTemplate.IPV6.title() + if obj.vm_type == VMTemplate.IPV6 else obj.name + ) + ) + for obj in VMTemplate.objects.all() + ) pricing = models.ForeignKey( VMPricing, related_name="dcl_custom_pricing_vm_pricing", @@ -303,3 +333,18 @@ class DCLCalculatorPluginModel(CMSPlugin): max_length=50, choices=VMTemplate.VM_TYPE_CHOICES, default=VMTemplate.PUBLIC ) + vm_templates_to_show = MultipleChoiceArrayField( + base_field=models.CharField( + blank=True, + max_length=256, + choices=VMTemplateChoices + ), + default=list, + blank=True, + help_text="Recommended: If you wish to show all templates of the " + "corresponding VM Type (public/ipv6only), please do not " + "select any of the items in the above field. " + "This will allow any new template(s) added " + "in the backend to be automatically listed in this " + "calculator instance." + ) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 9c6279bc..95a496d8 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -88,7 +88,7 @@ class DCLCalculatorPlugin(CMSPluginBase): context = super(DCLCalculatorPlugin, self).render( context, instance, placeholder ) - ids = instance.pricing.vm_templates_to_show + ids = instance.vm_templates_to_show if ids: context['templates'] = VMTemplate.objects.filter( vm_type=instance.vm_type diff --git a/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py b/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py new file mode 100644 index 00000000..179dcff9 --- /dev/null +++ b/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-06-24 06:54 +from __future__ import unicode_literals + +import datacenterlight.cms_models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0023_auto_20180524_0349'), + ] + + operations = [ + migrations.AddField( + model_name='dclcalculatorpluginmodel', + name='vm_templates_to_show', + field=datacenterlight.cms_models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, choices=[('4', 'CentOS 7'), ('14', 'Debian 8'), ('25', 'Ubuntu 14.04'), ('26', 'Ubuntu 16.04'), ('36', 'Devuan Jessie'), ('65', 'Devuan Ascii'), ('69', 'FreeBSD 11.1')], max_length=256), blank=True, default=list, help_text='Recommended: If you wish to show all templates of the corresponding VM Type (public/ipv6only), please do not select any of the items in the above field. This will allow any new template(s) added in the backend to be automatically listed in this calculator instance.', size=None), + ), + ] diff --git a/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py b/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py deleted file mode 100644 index 5705df5b..00000000 --- a/datacenterlight/migrations/0024_vmpricing_vm_templates_to_show.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-06-13 09:09 -from __future__ import unicode_literals - -import datacenterlight.models -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('datacenterlight', '0023_auto_20180524_0349'), - ] - - operations = [ - migrations.AddField( - model_name='vmpricing', - name='vm_templates_to_show', - field=datacenterlight.models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, choices=[('4', 'CentOS 7'), ('14', 'Debian 8'), ('25', 'Ubuntu 14.04'), ('26', 'Ubuntu 16.04'), ('36', 'Devuan Jessie'), ('65', 'Devuan Ascii'), ('69', 'FreeBSD 11.1')], max_length=256), blank=True, default=list, help_text='Not selecting any items above will result in showing all templates', size=None), - ), - ] diff --git a/datacenterlight/models.py b/datacenterlight/models.py index 3801465a..729bbdf9 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -1,7 +1,5 @@ import logging -from django import forms -from django.contrib.postgres.fields import ArrayField from django.db import models logger = logging.getLogger(__name__) @@ -34,31 +32,7 @@ class VMTemplate(models.Model): return vm_template -class MultipleChoiceArrayField(ArrayField): - """ - A field that allows us to store an array of choices. - Uses Django's Postgres ArrayField - and a MultipleChoiceField for its formfield. - """ - - def formfield(self, **kwargs): - defaults = { - 'form_class': forms.MultipleChoiceField, - 'choices': self.base_field.choices, - 'initial': [c[0] for c in self.base_field.choices], - } - defaults.update(kwargs) - # Skip our parent's formfield implementation completely as we don't - # care for it. - # pylint:disable=bad-super-call - return super(ArrayField, self).formfield(**defaults) - - class VMPricing(models.Model): - VMTemplateChoices = list( - (str(obj.opennebula_vm_template_id), obj.name) - for obj in VMTemplate.objects.all() - ) name = models.CharField(max_length=255, unique=True) vat_inclusive = models.BooleanField(default=True) vat_percentage = models.DecimalField( @@ -81,18 +55,6 @@ class VMPricing(models.Model): max_digits=6, decimal_places=2, default=0 ) - vm_templates_to_show = MultipleChoiceArrayField( - base_field=models.CharField( - blank=True, - max_length=256, - choices=VMTemplateChoices - ), - default=list, - blank=True, - help_text="Not selecting any items above will result in showing all " - "templates" - ) - def __str__(self): display_str = self.name + ' => ' + ' - '.join([ '{}/Core'.format(self.cores_unit_price.normalize()), From 70cac38f819bb67b50290e91a03afcb5bacdb4b6 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 10:28:17 +0200 Subject: [PATCH 54/60] Move initialization of VMTemplates out of the plugin --- datacenterlight/cms_models.py | 29 +++++++++---------- ...culatorpluginmodel_vm_templates_to_show.py | 4 +-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index deb84dc7..8c31696f 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -300,20 +300,6 @@ class MultipleChoiceArrayField(ArrayField): Uses Django's Postgres ArrayField and a MultipleChoiceField for its formfield. """ - - def formfield(self, **kwargs): - defaults = { - 'form_class': forms.MultipleChoiceField, - 'choices': self.base_field.choices, - } - defaults.update(kwargs) - # Skip our parent's formfield implementation completely as we don't - # care for it. - # pylint:disable=bad-super-call - return super(ArrayField, self).formfield(**defaults) - - -class DCLCalculatorPluginModel(CMSPlugin): VMTemplateChoices = list( ( str(obj.opennebula_vm_template_id), @@ -323,6 +309,20 @@ class DCLCalculatorPluginModel(CMSPlugin): ) for obj in VMTemplate.objects.all() ) + + def formfield(self, **kwargs): + defaults = { + 'form_class': forms.MultipleChoiceField, + 'choices': self.VMTemplateChoices, + } + defaults.update(kwargs) + # Skip our parent's formfield implementation completely as we don't + # care for it. + # pylint:disable=bad-super-call + return super(ArrayField, self).formfield(**defaults) + + +class DCLCalculatorPluginModel(CMSPlugin): pricing = models.ForeignKey( VMPricing, related_name="dcl_custom_pricing_vm_pricing", @@ -337,7 +337,6 @@ class DCLCalculatorPluginModel(CMSPlugin): base_field=models.CharField( blank=True, max_length=256, - choices=VMTemplateChoices ), default=list, blank=True, diff --git a/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py b/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py index 179dcff9..65bfce21 100644 --- a/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py +++ b/datacenterlight/migrations/0024_dclcalculatorpluginmodel_vm_templates_to_show.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-06-24 06:54 +# Generated by Django 1.9.4 on 2018-06-24 08:23 from __future__ import unicode_literals import datacenterlight.cms_models @@ -16,6 +16,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='dclcalculatorpluginmodel', name='vm_templates_to_show', - field=datacenterlight.cms_models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, choices=[('4', 'CentOS 7'), ('14', 'Debian 8'), ('25', 'Ubuntu 14.04'), ('26', 'Ubuntu 16.04'), ('36', 'Devuan Jessie'), ('65', 'Devuan Ascii'), ('69', 'FreeBSD 11.1')], max_length=256), blank=True, default=list, help_text='Recommended: If you wish to show all templates of the corresponding VM Type (public/ipv6only), please do not select any of the items in the above field. This will allow any new template(s) added in the backend to be automatically listed in this calculator instance.', size=None), + field=datacenterlight.cms_models.MultipleChoiceArrayField(base_field=models.CharField(blank=True, max_length=256), blank=True, default=list, help_text='Recommended: If you wish to show all templates of the corresponding VM Type (public/ipv6only), please do not select any of the items in the above field. This will allow any new template(s) added in the backend to be automatically listed in this calculator instance.', size=None), ), ] From fb9000de901737eb92ec8b1114e576628501ee1b Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 14:47:05 +0200 Subject: [PATCH 55/60] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 8146462d..045ab004 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +Next: + * feature: add vm_type option to vm_template and dcl calculator to distinguish between public and ipv6only templates (PR #635) 1.9: 2018-05-16 * #4559: [cms] enable discount on cms calculator 1.8: 2018-05-01 From 549e882ebe114880e31dbba720e3eff6d38d3ba3 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 14:54:50 +0200 Subject: [PATCH 56/60] Update Changelog --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 045ab004..2cf17fbe 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ Next: + * #4847: [comic] Add google analytics code for comic.ungleich.ch * feature: add vm_type option to vm_template and dcl calculator to distinguish between public and ipv6only templates (PR #635) 1.9: 2018-05-16 * #4559: [cms] enable discount on cms calculator From e816f65114b0f7463eb7c11f33c0c968b52d4df2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 16:00:54 +0200 Subject: [PATCH 57/60] Update Changelog --- Changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 2cf17fbe..df8b892f 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ Next: - * #4847: [comic] Add google analytics code for comic.ungleich.ch + * #4799: [dcl] Show selected vm templates only in calculator (PR #638) + * #4847: [comic] Add google analytics code for comic.ungleich.ch (PR #639) * feature: add vm_type option to vm_template and dcl calculator to distinguish between public and ipv6only templates (PR #635) 1.9: 2018-05-16 * #4559: [cms] enable discount on cms calculator From a5c42b9c44f93406631945c5409be5449931652f Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Jun 2018 17:05:33 +0200 Subject: [PATCH 58/60] Update Changelog for 1.9.1 --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index df8b892f..d175a734 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -Next: +1.9.1: 2018-06-24 * #4799: [dcl] Show selected vm templates only in calculator (PR #638) * #4847: [comic] Add google analytics code for comic.ungleich.ch (PR #639) * feature: add vm_type option to vm_template and dcl calculator to distinguish between public and ipv6only templates (PR #635) From 60260ccb0811299616c08e37c50ab922767cabdb Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 27 Jun 2018 09:06:28 +0200 Subject: [PATCH 59/60] Attempt to fix flake8 error --- datacenterlight/cms_models.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 8c31696f..62a7b312 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -3,6 +3,7 @@ from cms.extensions.extension_pool import extension_pool from cms.models.fields import PlaceholderField from cms.models.pluginmodel import CMSPlugin from django import forms +from django.conf import settings from django.contrib.postgres.fields import ArrayField from django.contrib.sites.models import Site from django.db import models @@ -300,15 +301,17 @@ class MultipleChoiceArrayField(ArrayField): Uses Django's Postgres ArrayField and a MultipleChoiceField for its formfield. """ - VMTemplateChoices = list( - ( - str(obj.opennebula_vm_template_id), - (obj.name + ' - ' + VMTemplate.IPV6.title() - if obj.vm_type == VMTemplate.IPV6 else obj.name + VMTemplateChoices = [] + if settings.OPENNEBULA_DOMAIN != 'test_domain': + VMTemplateChoices = list( + ( + str(obj.opennebula_vm_template_id), + (obj.name + ' - ' + VMTemplate.IPV6.title() + if obj.vm_type == VMTemplate.IPV6 else obj.name + ) ) - ) - for obj in VMTemplate.objects.all() - ) + for obj in VMTemplate.objects.all() + ) def formfield(self, **kwargs): defaults = { From 88f0d733365f68db9ba8ec1274125251548bef73 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 27 Jun 2018 09:21:41 +0200 Subject: [PATCH 60/60] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index d175a734..d616964f 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +Next: + * bugfix: Fix flake8 error that was ignored in release 1.9.1 1.9.1: 2018-06-24 * #4799: [dcl] Show selected vm templates only in calculator (PR #638) * #4847: [comic] Add google analytics code for comic.ungleich.ch (PR #639)