From bc368491784502bb72fa0b3a784a2aa8a70692b2 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 27 Mar 2018 19:19:26 +0530 Subject: [PATCH 1/6] cms integration --- datacenterlight/admin.py | 10 +++++++ datacenterlight/cms_models.py | 11 ++++++++ .../static/datacenterlight/css/common.css | 2 +- .../datacenterlight/base_hosting.html | 10 ++++--- .../datacenterlight/landing_payment.html | 2 +- datacenterlight/views.py | 28 +++++++++++-------- 6 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 datacenterlight/admin.py diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py new file mode 100644 index 00000000..974006a6 --- /dev/null +++ b/datacenterlight/admin.py @@ -0,0 +1,10 @@ +from django.contrib import admin +from cms.admin.placeholderadmin import PlaceholderAdminMixin +from .cms_models import CMSIntegration + + +class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin): + pass + + +admin.site.register(CMSIntegration, CMSIntegrationAdmin) diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 8c9ae740..fa01f18a 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -3,6 +3,17 @@ from django.db import models from django.utils.safestring import mark_safe from djangocms_text_ckeditor.fields import HTMLField from filer.fields.image import FilerImageField +from cms.models.fields import PlaceholderField + + +class CMSIntegration(models.Model): + name = models.CharField( + max_length=100, unique=True, default='default', + help_text='An optional heading for the Section', + ) + footer_placeholder = PlaceholderField('datacenterlight_footer') + navbar_placeholder = PlaceholderField('datacenterlight_navbar') + # Models for CMS Plugins diff --git a/datacenterlight/static/datacenterlight/css/common.css b/datacenterlight/static/datacenterlight/css/common.css index e24cf671..87569ae1 100644 --- a/datacenterlight/static/datacenterlight/css/common.css +++ b/datacenterlight/static/datacenterlight/css/common.css @@ -1,7 +1,7 @@ body, html { width: 100%; - min-height: 100%; + height: 100%; } body, diff --git a/datacenterlight/templates/datacenterlight/base_hosting.html b/datacenterlight/templates/datacenterlight/base_hosting.html index 7e4f7fac..20111878 100644 --- a/datacenterlight/templates/datacenterlight/base_hosting.html +++ b/datacenterlight/templates/datacenterlight/base_hosting.html @@ -1,4 +1,4 @@ -{% load staticfiles i18n %} +{% load staticfiles i18n cms_tags sekizai_tags %} {% get_current_language as LANGUAGE_CODE %} @@ -26,6 +26,9 @@ {% block css_extra %} {% endblock css_extra %} + {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} + {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %} + @@ -43,10 +46,9 @@ + {% cms_toolbar %} - {% block navbar %} - {% include "hosting/includes/_navbar_user.html" %} - {% endblock navbar %} + {% render_placeholder cms_integration.navbar_placeholder %}
{% block content %} diff --git a/datacenterlight/templates/datacenterlight/landing_payment.html b/datacenterlight/templates/datacenterlight/landing_payment.html index 8e779576..e64d8ca3 100644 --- a/datacenterlight/templates/datacenterlight/landing_payment.html +++ b/datacenterlight/templates/datacenterlight/landing_payment.html @@ -1,5 +1,5 @@ {% extends "datacenterlight/base_hosting.html" %} -{% load staticfiles bootstrap3 i18n %} +{% load staticfiles bootstrap3 i18n cms_tags %} {% block css_extra %} diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 5517abaf..e2241a17 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -18,14 +18,13 @@ from hosting.forms import HostingUserLoginForm from hosting.models import HostingOrder from membership.models import CustomUser, StripeCustomer from opennebula_api.serializers import VMTemplateSerializer -from utils.forms import ( - BillingAddressForm, BillingAddressFormSignup -) +from utils.forms import BillingAddressForm, BillingAddressFormSignup from utils.hosting_utils import get_vm_price from utils.stripe_utils import StripeUtils from utils.tasks import send_plain_email_task from .forms import ContactForm from .models import VMTemplate +from .cms_models import CMSIntegration logger = logging.getLogger(__name__) @@ -42,9 +41,10 @@ class ContactUsView(FormView): return self.render_to_response( self.get_context_data(contact_form=form)) else: - return render(self.request, - 'datacenterlight/index.html', - self.get_context_data(contact_form=form)) + return render( + self.request, 'datacenterlight/index.html', + self.get_context_data(contact_form=form) + ) def form_valid(self, form): form.save() @@ -68,10 +68,10 @@ class ContactUsView(FormView): return self.render_to_response( self.get_context_data(success=True, contact_form=form)) else: - return render(self.request, - 'datacenterlight/index.html', - self.get_context_data(success=True, - contact_form=form)) + return render( + self.request, 'datacenterlight/index.html', + self.get_context_data(success=True, contact_form=form) + ) class IndexView(CreateView): @@ -219,7 +219,8 @@ class PaymentOrderView(FormView): 'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'site_url': reverse('datacenterlight:index'), 'login_form': HostingUserLoginForm(prefix='login_form'), - 'billing_address_form': billing_address_form + 'billing_address_form': billing_address_form, + 'cms_integration': CMSIntegration.objects.get(name='default') }) return context @@ -354,7 +355,10 @@ class OrderConfirmationView(DetailView): 'cc_brand': card_details.get('response_object').get('brand'), 'vm': request.session.get('specs'), 'page_header_text': _('Confirm Order'), - 'billing_address_data': request.session.get('billing_address_data') + 'billing_address_data': ( + request.session.get('billing_address_data') + ), + 'cms_integration': CMSIntegration.objects.get(name='default') } return render(request, self.template_name, context) From d52c061709d24a8605b205d8c705f6742199b10b Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 27 Mar 2018 19:38:09 +0530 Subject: [PATCH 2/6] use humanize to add comma to numbers --- .../templates/datacenterlight/landing_payment.html | 4 ++-- .../templates/datacenterlight/order_detail.html | 8 ++++---- dynamicweb/settings/base.py | 3 +-- hosting/templates/hosting/order_detail.html | 9 ++++----- hosting/templates/hosting/orders.html | 5 ++--- hosting/templates/hosting/payment.html | 6 +++--- hosting/templates/hosting/virtual_machine_detail.html | 6 +++--- hosting/templates/hosting/virtual_machines.html | 4 ++-- 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/datacenterlight/templates/datacenterlight/landing_payment.html b/datacenterlight/templates/datacenterlight/landing_payment.html index 8e779576..60da04bf 100644 --- a/datacenterlight/templates/datacenterlight/landing_payment.html +++ b/datacenterlight/templates/datacenterlight/landing_payment.html @@ -1,5 +1,5 @@ {% extends "datacenterlight/base_hosting.html" %} -{% load staticfiles bootstrap3 i18n %} +{% load staticfiles bootstrap3 i18n humanize %} {% block css_extra %} @@ -78,7 +78,7 @@

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


-

{%trans "Total" %}  ({%trans "including VAT" %}) {{request.session.specs.price}} CHF/{% trans "Month" %}

+

{%trans "Total" %}  ({%trans "including VAT" %}) {{request.session.specs.price|intcomma}} CHF/{% trans "Month" %}

diff --git a/datacenterlight/templates/datacenterlight/order_detail.html b/datacenterlight/templates/datacenterlight/order_detail.html index 6b103970..78ed43c0 100644 --- a/datacenterlight/templates/datacenterlight/order_detail.html +++ b/datacenterlight/templates/datacenterlight/order_detail.html @@ -1,5 +1,5 @@ {% extends "datacenterlight/base_hosting.html" %} -{% load staticfiles bootstrap3 i18n custom_tags %} +{% load staticfiles bootstrap3 i18n custom_tags humanize %} {% block content %}
@@ -59,15 +59,15 @@

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

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

{% trans "Total" %} - {{vm.price}} CHF + {{vm.price|intcomma}} CHF

diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index ae6f8132..5db5a498 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -82,6 +82,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', + 'django.contrib.humanize', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', @@ -255,8 +256,6 @@ USE_L10N = True USE_TZ = True -USE_THOUSAND_SEPARATOR = True - FORMAT_MODULE_PATH = [ 'dynamicweb.formats' ] diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index f40ee34c..f5ee80b6 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -1,7 +1,6 @@ {% extends "hosting/base_short.html" %} -{% load staticfiles bootstrap3 %} -{% load i18n %} -{% load custom_tags %} +{% load staticfiles bootstrap3 humanize i18n custom_tags %} + {% block content %}
@@ -130,7 +129,7 @@

{% trans "Total" %} - {{vm.price}} CHF + {{vm.price|intcomma}} CHF

@@ -143,7 +142,7 @@ {% csrf_token %}
-
{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price }}CHF/month{% endblocktrans %}.
+
{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price|intcomma }}CHF/month{% endblocktrans %}.
diff --git a/hosting/templates/hosting/virtual_machines.html b/hosting/templates/hosting/virtual_machines.html index ce1656ae..467d9d39 100644 --- a/hosting/templates/hosting/virtual_machines.html +++ b/hosting/templates/hosting/virtual_machines.html @@ -1,5 +1,5 @@ {% extends "hosting/base_short.html" %} -{% load staticfiles bootstrap3 i18n l10n %} +{% load staticfiles bootstrap3 i18n %} {% block content %}
@@ -40,7 +40,7 @@ {% for vm in vms %} - {{vm.vm_id|unlocalize}} + {{vm.vm_id}} {% if vm.ipv4 %}{{vm.ipv4}}{% endif %} {% if vm.ipv6 %}{{vm.ipv6}}{% endif %} From 8beebbf487edbc6abffa39da3d4f58e7623920b7 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 27 Mar 2018 20:57:46 +0530 Subject: [PATCH 3/6] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index aa0d73bf..1c0be867 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +next + * bgfix: fix header slider interval issue 1.6: 2018-03-25 * #4266: [dcl cms] add promotional section plugin * #3842: [dcl, hosting] change number formatting for all the numbers from german to english locale From e7d7cf67b29ec84296a2823923aae41f8cbd0aef Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 27 Mar 2018 21:04:44 +0530 Subject: [PATCH 4/6] add footer and header placeholders --- datacenterlight/cms_models.py | 8 +++- .../migrations/0016_cmsintegration.py | 31 +++++++++++++++ .../static/datacenterlight/css/common.css | 37 +++++++++++++++++- .../static/datacenterlight/css/hosting.css | 20 +++++----- .../datacenterlight/css/landing-page.css | 38 +------------------ .../datacenterlight/base_hosting.html | 17 +++------ 6 files changed, 90 insertions(+), 61 deletions(-) create mode 100644 datacenterlight/migrations/0016_cmsintegration.py diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index fa01f18a..969deafa 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -9,11 +9,17 @@ from cms.models.fields import PlaceholderField class CMSIntegration(models.Model): name = models.CharField( max_length=100, unique=True, default='default', - help_text='An optional heading for the Section', + help_text=( + 'A unique name for the Integration. This name will be used to ' + 'fetch the Integration into pages' + ) ) footer_placeholder = PlaceholderField('datacenterlight_footer') navbar_placeholder = PlaceholderField('datacenterlight_navbar') + def __str__(self): + return self.name + # Models for CMS Plugins diff --git a/datacenterlight/migrations/0016_cmsintegration.py b/datacenterlight/migrations/0016_cmsintegration.py new file mode 100644 index 00000000..bdd1813a --- /dev/null +++ b/datacenterlight/migrations/0016_cmsintegration.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-03-27 15:31 +from __future__ import unicode_literals + +import cms.models.fields +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0015_auto_20180323_0011'), + ('cms', '0014_auto_20160404_1908'), + ] + + operations = [ + migrations.CreateModel( + name='CMSIntegration', + fields=[ + ('id', models.AutoField(auto_created=True, + primary_key=True, serialize=False, verbose_name='ID')), + ('navbar_placeholder', cms.models.fields.PlaceholderField(editable=False, null=True, + on_delete=django.db.models.deletion.CASCADE, slotname='datacenterlight_navbar', to='cms.Placeholder')), + ('footer_placeholder', cms.models.fields.PlaceholderField(editable=False, null=True, + on_delete=django.db.models.deletion.CASCADE, slotname='datacenterlight_footer', to='cms.Placeholder')), + ('name', models.CharField(default='default', + help_text='A unique name for the Integration. This name will be used to fetch the Integration into pages', max_length=100, unique=True)), + ], + ), + ] diff --git a/datacenterlight/static/datacenterlight/css/common.css b/datacenterlight/static/datacenterlight/css/common.css index 87569ae1..214dbfd9 100644 --- a/datacenterlight/static/datacenterlight/css/common.css +++ b/datacenterlight/static/datacenterlight/css/common.css @@ -84,8 +84,24 @@ a.list-group-item-danger.active:focus { } } +.navbar .dcl-link { + display: block; + padding: 15px; + color: #777; +} + +.navbar .dcl-link:focus, +.navbar .dcl-link:active, +.navbar .dcl-link:hover { + text-decoration: none; +} + +.navbar .dropdown-menu .dcl-link { + padding: 1px 10px; +} + p.copyright { - margin: 15px 0 0; + margin: 15px 0; } footer { @@ -95,4 +111,23 @@ footer { footer a { color: #777; +} + +footer .dcl-link-separator { + position: relative; + padding-left: 10px; +} + +footer .dcl-link-separator::before { + content: ""; + position: absolute; + display: inline-block; + top: 9px; + bottom: 0; + left: -2px; + right: 0; + width: 2px; + height: 2px; + border-radius: 100%; + background: #777; } \ No newline at end of file diff --git a/datacenterlight/static/datacenterlight/css/hosting.css b/datacenterlight/static/datacenterlight/css/hosting.css index 800fb533..8769ed60 100644 --- a/datacenterlight/static/datacenterlight/css/hosting.css +++ b/datacenterlight/static/datacenterlight/css/hosting.css @@ -15,8 +15,8 @@ } @media(min-width: 768px) { - .navbar-default .navbar-nav>li>a, - .navbar-right .highlights-dropdown .dropdown-menu>li>a { + .navbar-default .navbar-nav>li a, + .navbar-right .highlights-dropdown .dropdown-menu>li a { font-weight: 300; } .navbar-right .highlights-dropdown .dropdown-menu { @@ -26,7 +26,7 @@ } } -.navbar-right .highlights-dropdown .dropdown-menu>li>a { +.navbar-right .highlights-dropdown .dropdown-menu>li a { font-size: 13px; font-family: 'Lato', sans-serif; padding: 1px 10px 1px 18px !important; @@ -34,9 +34,9 @@ color: #333; } -.navbar-right .highlights-dropdown .dropdown-menu>li>a:hover, -.navbar-right .highlights-dropdown .dropdown-menu>li>a:focus, -.navbar-right .highlights-dropdown .dropdown-menu>li>a:active { +.navbar-right .highlights-dropdown .dropdown-menu>li a:hover, +.navbar-right .highlights-dropdown .dropdown-menu>li a:focus, +.navbar-right .highlights-dropdown .dropdown-menu>li a:active { background: transparent; text-decoration: underline !important; } @@ -144,9 +144,9 @@ } @media (max-width: 767px) { - .navbar-default .navbar-nav .open .dropdown-menu>.active>a, - .navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus, - .navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover { + .navbar-default .navbar-nav .open .dropdown-menu>.active a, + .navbar-default .navbar-nav .open .dropdown-menu>.active a:focus, + .navbar-default .navbar-nav .open .dropdown-menu>.active a:hover { background-color: transparent; } } @@ -163,7 +163,7 @@ } .content-dashboard { - min-height: calc(100vh - 60px); + min-height: calc(100vh - 86px); width: 100%; margin: 0 auto; max-width: 1120px; diff --git a/datacenterlight/static/datacenterlight/css/landing-page.css b/datacenterlight/static/datacenterlight/css/landing-page.css index 3ac46295..38e84a59 100755 --- a/datacenterlight/static/datacenterlight/css/landing-page.css +++ b/datacenterlight/static/datacenterlight/css/landing-page.css @@ -99,15 +99,13 @@ textarea { } } +.navbar-transparent .navbar-nav>li a, .navbar-transparent .navbar-nav>.open>a, .navbar-transparent .navbar-nav>.open>a:focus, .navbar-transparent .navbar-nav>.open>a:hover { color: #fff; } -.navbar-transparent .navbar-nav>li a { - color: #fff; -} .navbar-transparent .navbar-nav>li a:focus, .navbar-transparent .navbar-nav>li a:active, @@ -123,22 +121,6 @@ textarea { background: transparent; } -.navbar .dcl-link { - display: block; - padding: 15px; - color: #777; -} - -.navbar .dcl-link:focus, -.navbar .dcl-link:active, -.navbar .dcl-link:hover { - text-decoration: none; -} - -.navbar .dropdown-menu .dcl-link { - padding: 1px 10px; -} - .navbar-transparent .navbar-nav>li>.on-hover-border { transition: all 0.3s linear; box-shadow: none; @@ -1233,24 +1215,6 @@ footer { transform: rotate(45deg); } -footer .dcl-link-separator { - position: relative; - padding-left: 10px; -} - -footer .dcl-link-separator::before { - content: ""; - position: absolute; - display: inline-block; - top: 9px; - bottom: 0; - left: -2px; - right: 0; - width: 2px; - height: 2px; - border-radius: 100%; - background: #777; -} /* new styles for whydcl section cms plugin (to replace older style) */ diff --git a/datacenterlight/templates/datacenterlight/base_hosting.html b/datacenterlight/templates/datacenterlight/base_hosting.html index 20111878..e1ca1bb4 100644 --- a/datacenterlight/templates/datacenterlight/base_hosting.html +++ b/datacenterlight/templates/datacenterlight/base_hosting.html @@ -23,6 +23,9 @@ + {% if request.toolbar.edit_mode %} + + {% endif %} {% block css_extra %} {% endblock css_extra %} @@ -55,18 +58,8 @@ {% endblock %}
- - {% if request.user.is_authenticated %} -
-
- -
-
- {% else %} - - {% endif %} + {% render_placeholder cms_integration.footer_placeholder %} + From 2b27d56e54e490f27f15498bee18f30c655fc39c Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 29 Mar 2018 00:43:38 +0530 Subject: [PATCH 5/6] cmsintegrate management command --- datacenterlight/management/commands/cmsintegrate.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 datacenterlight/management/commands/cmsintegrate.py diff --git a/datacenterlight/management/commands/cmsintegrate.py b/datacenterlight/management/commands/cmsintegrate.py new file mode 100644 index 00000000..5b4f72d2 --- /dev/null +++ b/datacenterlight/management/commands/cmsintegrate.py @@ -0,0 +1,13 @@ +from django.core.management.base import BaseCommand +from datacenterlight.cms_models import CMSIntegration + + +class Command(BaseCommand): + help = '''Creates cms integration objects for datacenterlight''' + + def handle(self, *args, **options): + obj, created = CMSIntegration.objects.get_or_create(name='default') + if created: + print('created the default CMSIntegration object') + else: + print('default CMSIntegration object already exists') From 29a2ee098b7092d41c03cbec98e7a0643b524806 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 29 Mar 2018 00:58:08 +0530 Subject: [PATCH 6/6] fix related name for placeholder fields --- datacenterlight/cms_models.py | 8 ++++-- .../migrations/0017_auto_20180329_0056.py | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 datacenterlight/migrations/0017_auto_20180329_0056.py diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 969deafa..a1f285fa 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -14,8 +14,12 @@ class CMSIntegration(models.Model): 'fetch the Integration into pages' ) ) - footer_placeholder = PlaceholderField('datacenterlight_footer') - navbar_placeholder = PlaceholderField('datacenterlight_navbar') + footer_placeholder = PlaceholderField( + 'datacenterlight_footer', related_name='dcl-footer-placeholder+' + ) + navbar_placeholder = PlaceholderField( + 'datacenterlight_navbar', related_name='dcl-navbar-placeholder+' + ) def __str__(self): return self.name diff --git a/datacenterlight/migrations/0017_auto_20180329_0056.py b/datacenterlight/migrations/0017_auto_20180329_0056.py new file mode 100644 index 00000000..136e6dbd --- /dev/null +++ b/datacenterlight/migrations/0017_auto_20180329_0056.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-03-28 19:26 +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', '0016_cmsintegration'), + ] + + operations = [ + migrations.AlterField( + model_name='cmsintegration', + name='footer_placeholder', + field=cms.models.fields.PlaceholderField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dcl-footer-placeholder+', slotname='datacenterlight_footer', to='cms.Placeholder'), + ), + migrations.AlterField( + model_name='cmsintegration', + name='navbar_placeholder', + field=cms.models.fields.PlaceholderField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dcl-navbar-placeholder+', slotname='datacenterlight_navbar', to='cms.Placeholder'), + ), + ]