diff --git a/Changelog b/Changelog index 0ed32a90..3daf9288 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -Next release: +1.2.7: 2017-10-20 * Bugfix: [dcl, hosting] Fix Stripe js error in confirm payment page * #3847: [ungleich] change text 'hosting products' -> 'our products' * #3829: [dcl] Handle landing login fail in payment page itself @@ -6,6 +6,7 @@ Next release: * #3828: [dcl, hosting] invoice period set to show monthly subscription * #3838: [hosting] restyle signup/login/password reset/password pages * Bugfix: [dg] Remove validate email link in the registration email + * Feature: [ungleich_page] Add new glasfaser CMS template 1.2.6: 2017-10-10 * Bugfix: [dcl] Refactor and optimize images, links in glasfaser page * Bugfix: [dcl] Fix email not being sent issue diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 170ae3a8..48a2399f 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -218,6 +218,7 @@ CMS_TEMPLATES = ( ('page.html', gettext('Page')), # dcl ('datacenterlight/cms_page.html', gettext('Data Center Light')), + ('ungleich_page/glasfaser_cms_page.html', gettext('Glasfaser')), ) DATABASES = { diff --git a/ungleich_page/cms_menus.py b/ungleich_page/cms_menus.py new file mode 100644 index 00000000..b347243e --- /dev/null +++ b/ungleich_page/cms_menus.py @@ -0,0 +1,62 @@ +from menus.base import NavigationNode +from menus.menu_pool import menu_pool +from django.utils.translation import ugettext_lazy as _ +from cms.menu_bases import CMSAttachMenu +from cms.templatetags.cms_tags import _get_placeholder +from cms.utils.plugins import get_plugins + + +class GlasfaserMenu(CMSAttachMenu): + + name = _("Glasfaser menu") + + def get_nodes(self, request): + nodes = [] + glasfaser_cms = 'ungleich_page/glasfaser_cms_page.html' + if request and request.current_page.get_template() == glasfaser_cms: + template_context = { + "request": request, + } + placeholder_name_list = [ + 'Top Section', 'Middle Section', 'Glasfaser Services', + 'Glasfaser About', 'Contact Section' + ] + plugins_list = [ + 'SectionWithImage', 'UngelichContactUsSection', + 'UngelichTextSection', 'Service', 'About' + ] + for placeholder_name in placeholder_name_list: + placeholder = _get_placeholder( + request.current_page, request.current_page, + template_context, placeholder_name + ) + plugins = get_plugins( + request, placeholder, request.current_page.get_template() + ) + for plugin in plugins: + if type(plugin).__name__ in plugins_list: + section_hash = request.build_absolute_uri() + if hasattr(plugin, 'menu_text'): + menu_text = plugin.menu_text + if menu_text.strip() == '': + continue + menu_words = menu_text.split() + if len(menu_words) > 0: + section_hash = '{}#{}'.format( + section_hash, + menu_words[0] + ) + else: + continue + newnode = NavigationNode( + menu_text, + url=section_hash, + id="{}-{}".format( + request.current_page.id, plugin.id + ) + ) + nodes.append(newnode) + return nodes + + +menu_pool.register_menu(GlasfaserMenu) diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py new file mode 100644 index 00000000..a5b10d5f --- /dev/null +++ b/ungleich_page/cms_plugins.py @@ -0,0 +1,147 @@ +from cms.plugin_base import CMSPluginBase +from cms.plugin_pool import plugin_pool + +from .models import ( + UngelichContactUsSection, UngelichTextSection, Service, ServiceItem, + About, AboutItem, SectionWithImage +) + + +def get_section_id(plugin_instance, default): + """ + A helper function to get the section id from a given menu text + :param plugin_instance: + :param default: The default section id to return in case a section id + is not found + :return: The section id for the plugin_instance + """ + section_id = default + if hasattr(plugin_instance, 'menu_text'): + menu_words = plugin_instance.menu_text.split() + if len(menu_words) > 0: + section_id = menu_words[0] + return section_id + + +@plugin_pool.register_plugin +class SectionWithImagePlugin(CMSPluginBase): + model = SectionWithImage + render_template = "ungleich_page/glasfaser/section_with_image.html" + cache = False + + def render(self, context, instance, placeholder): + context.update({ + 'image': instance.image, + 'object': instance, + 'placeholder': placeholder + }) + return context + + +@plugin_pool.register_plugin +class SectionContact(CMSPluginBase): + model = UngelichContactUsSection + render_template = "ungleich_page/glasfaser/section_contact.html" + cache = False + + def render(self, context, instance, placeholder): + context = super(SectionContact, self).render( + context, instance, placeholder + ) + context['instance'] = instance + context['section_id'] = get_section_id(instance, 'contact') + return context + + +@plugin_pool.register_plugin +class SectionTextParagraphDCL(CMSPluginBase): + model = UngelichTextSection + render_template = "ungleich_page/glasfaser/section_text_dcl.html" + cache = False + + def render(self, context, instance, placeholder): + context = super(SectionTextParagraphDCL, self).render( + context, instance, placeholder + ) + context['instance'] = instance + context['section_id'] = get_section_id(instance, 'your') + return context + + +@plugin_pool.register_plugin +class SectionTextParagraphGlasfaser(CMSPluginBase): + model = UngelichTextSection + render_template = "ungleich_page/glasfaser/section_text_glasfaser.html" + cache = False + + def render(self, context, instance, placeholder): + context = super(SectionTextParagraphGlasfaser, self).render( + context, instance, placeholder + ) + context['instance'] = instance + context['section_id'] = get_section_id(instance, 'our') + return context + + +@plugin_pool.register_plugin +class GlasfaserServicesPlugin(CMSPluginBase): + name = "Glasfaser Services Plugin" + model = Service + render_template = "ungleich_page/glasfaser/section_services.html" + cache = False + allow_children = True + child_classes = ['GlasfaserServicesItemPlugin'] + + def render(self, context, instance, placeholder): + context['service_instance'] = instance + context['section_id'] = get_section_id(instance, 'services') + return context + + +@plugin_pool.register_plugin +class GlasfaserServicesItemPlugin(CMSPluginBase): + name = "Glasfaser Service Item Plugin" + model = ServiceItem + render_template = "ungleich_page/glasfaser/_services_item.html" + cache = False + require_parent = True + parent_classes = ['GlasfaserServicesPlugin'] + + def render(self, context, instance, placeholder): + context = super(GlasfaserServicesItemPlugin, self).render( + context, instance, placeholder + ) + context['instance'] = instance + return context + + +@plugin_pool.register_plugin +class GlasfaserAboutPlugin(CMSPluginBase): + name = "Glasfaser About Plugin" + model = About + render_template = "ungleich_page/glasfaser/section_about.html" + cache = False + allow_children = True + child_classes = ['GlasfaserAboutItemPlugin'] + + def render(self, context, instance, placeholder): + context['about_instance'] = instance + context['section_id'] = get_section_id(instance, 'about') + return context + + +@plugin_pool.register_plugin +class GlasfaserAboutItemPlugin(CMSPluginBase): + name = "Glasfaser About Item Plugin" + model = AboutItem + render_template = "ungleich_page/glasfaser/_about_item.html" + cache = False + require_parent = True + parent_classes = ['GlasfaserAboutPlugin'] + + def render(self, context, instance, placeholder): + context = super(GlasfaserAboutItemPlugin, self).render( + context, instance, placeholder + ) + context['instance'] = instance + return context diff --git a/ungleich_page/migrations/0001_initial.py b/ungleich_page/migrations/0001_initial.py new file mode 100644 index 00000000..f9be10dc --- /dev/null +++ b/ungleich_page/migrations/0001_initial.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-18 18:23 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import djangocms_text_ckeditor.fields +import filer.fields.image + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('filer', '0004_auto_20160328_1434'), + ('cms', '0014_auto_20160404_1908'), + ] + + operations = [ + migrations.CreateModel( + name='Service', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')), + ('title', models.CharField(max_length=200)), + ('sub_title', models.CharField(max_length=200)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='ServiceItem', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')), + ('title', models.CharField(max_length=200)), + ('description', djangocms_text_ckeditor.fields.HTMLField()), + ('image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='service_item_image', to='filer.Image')), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='UngelichContactUsSection', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')), + ('email', models.EmailField(max_length=200)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='UngelichPicture', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')), + ('title', models.CharField(max_length=400)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='UngelichTextSection', + fields=[ + ('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cms.CMSPlugin')), + ('title', models.CharField(max_length=200)), + ('description', djangocms_text_ckeditor.fields.HTMLField()), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='About', + fields=[ + ('service_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.Service')), + ], + options={ + 'abstract': False, + }, + bases=('ungleich_page.service',), + ), + migrations.CreateModel( + name='AboutItem', + fields=[ + ('ungelichpicture_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.UngelichPicture')), + ('inverted', models.BooleanField(default=False)), + ], + options={ + 'abstract': False, + }, + bases=('ungleich_page.ungelichpicture',), + ), + migrations.AddField( + model_name='ungelichpicture', + name='image', + field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='image', to='filer.Image'), + ), + ] diff --git a/ungleich_page/migrations/0002_sectionwithimage.py b/ungleich_page/migrations/0002_sectionwithimage.py new file mode 100644 index 00000000..87e742b3 --- /dev/null +++ b/ungleich_page/migrations/0002_sectionwithimage.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-18 22:02 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import filer.fields.image + + +class Migration(migrations.Migration): + + dependencies = [ + ('filer', '0004_auto_20160328_1434'), + ('ungleich_page', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='SectionWithImage', + fields=[ + ('ungelichpicture_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.UngelichPicture')), + ('price_tag_url', models.URLField(default='', max_length=300)), + ('price_tag_image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='price_tag_image', to='filer.Image')), + ], + options={ + 'abstract': False, + }, + bases=('ungleich_page.ungelichpicture',), + ), + ] diff --git a/ungleich_page/migrations/0003_auto_20171019_1007.py b/ungleich_page/migrations/0003_auto_20171019_1007.py new file mode 100644 index 00000000..33f19a29 --- /dev/null +++ b/ungleich_page/migrations/0003_auto_20171019_1007.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-19 10:07 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ungleich_page', '0002_sectionwithimage'), + ] + + operations = [ + migrations.AddField( + model_name='sectionwithimage', + name='menu_text', + field=models.CharField(default='', max_length=100), + ), + migrations.AddField( + model_name='service', + name='menu_text', + field=models.CharField(default='', max_length=100), + ), + migrations.AddField( + model_name='ungelichcontactussection', + name='menu_text', + field=models.CharField(default='', max_length=100), + ), + migrations.AddField( + model_name='ungelichtextsection', + name='menu_text', + field=models.CharField(default='', max_length=100), + ), + ] diff --git a/ungleich_page/migrations/0004_auto_20171019_1113.py b/ungleich_page/migrations/0004_auto_20171019_1113.py new file mode 100644 index 00000000..b1877091 --- /dev/null +++ b/ungleich_page/migrations/0004_auto_20171019_1113.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-19 11:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ungleich_page', '0003_auto_20171019_1007'), + ] + + operations = [ + migrations.AlterField( + model_name='sectionwithimage', + name='menu_text', + field=models.CharField(blank=True, default='', max_length=100), + ), + migrations.AlterField( + model_name='sectionwithimage', + name='price_tag_url', + field=models.URLField(blank=True, default='', max_length=300), + ), + migrations.AlterField( + model_name='service', + name='menu_text', + field=models.CharField(blank=True, default='', max_length=100), + ), + migrations.AlterField( + model_name='ungelichcontactussection', + name='menu_text', + field=models.CharField(blank=True, default='', max_length=100), + ), + migrations.AlterField( + model_name='ungelichtextsection', + name='menu_text', + field=models.CharField(blank=True, default='', max_length=100), + ), + ] diff --git a/ungleich_page/migrations/0005_auto_20171019_1517.py b/ungleich_page/migrations/0005_auto_20171019_1517.py new file mode 100644 index 00000000..915f3582 --- /dev/null +++ b/ungleich_page/migrations/0005_auto_20171019_1517.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-19 15:17 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ungleich_page', '0004_auto_20171019_1113'), + ] + + operations = [ + migrations.AddField( + model_name='ungelichcontactussection', + name='address', + field=models.CharField(blank=True, default='In der Au 7, Schwanden 8762', max_length=100), + ), + migrations.AddField( + model_name='ungelichcontactussection', + name='contact_form_header_text', + field=models.CharField(blank=True, default='Send us a message.', max_length=100), + ), + migrations.AddField( + model_name='ungelichcontactussection', + name='contact_text', + field=models.CharField(blank=True, default='Contact', max_length=100), + ), + migrations.AddField( + model_name='ungelichcontactussection', + name='country', + field=models.CharField(blank=True, default='Switzerland', max_length=100), + ), + migrations.AddField( + model_name='ungelichcontactussection', + name='organization_name', + field=models.CharField(blank=True, default='ungleich GmbH', max_length=100), + ), + migrations.AlterField( + model_name='ungelichcontactussection', + name='email', + field=models.EmailField(default='info@ungleich.ch', max_length=200), + ), + ] diff --git a/ungleich_page/migrations/0006_aboutitem_link_url.py b/ungleich_page/migrations/0006_aboutitem_link_url.py new file mode 100644 index 00000000..ebb20e79 --- /dev/null +++ b/ungleich_page/migrations/0006_aboutitem_link_url.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-10-20 06:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ungleich_page', '0005_auto_20171019_1517'), + ] + + operations = [ + migrations.AddField( + model_name='aboutitem', + name='link_url', + field=models.URLField(blank=True, default='', max_length=300), + ), + ] diff --git a/ungleich_page/models.py b/ungleich_page/models.py index 0b4331b3..3759ee25 100644 --- a/ungleich_page/models.py +++ b/ungleich_page/models.py @@ -1,3 +1,89 @@ -# from django.db import models +from cms.models.pluginmodel import CMSPlugin +from django.db import models +from djangocms_text_ckeditor.fields import HTMLField +from filer.fields.image import FilerImageField -# Create your models here. + +class UngelichPicture(CMSPlugin): + image = FilerImageField( + null=True, + blank=True, + related_name="image", + on_delete=models.SET_NULL + ) + title = models.CharField(max_length=400) + + +class SectionWithImage(UngelichPicture): + menu_text = models.CharField(max_length=100, default="", blank=True) + price_tag_image = FilerImageField( + null=True, + blank=True, + related_name="price_tag_image", + on_delete=models.SET_NULL + ) + price_tag_url = models.URLField(max_length=300, default="", blank=True) + + +class UngelichContactUsSection(CMSPlugin): + menu_text = models.CharField(max_length=100, default="", blank=True) + email = models.EmailField(max_length=200, default="info@ungleich.ch") + contact_text = models.CharField( + max_length=100, default="Contact", blank=True + ) + organization_name = models.CharField( + max_length=100, default="ungleich GmbH", blank=True + ) + address = models.CharField( + max_length=100, default="In der Au 7, Schwanden 8762", blank=True + ) + country = models.CharField( + max_length=100, default="Switzerland", blank=True + ) + contact_form_header_text = models.CharField( + max_length=100, default="Send us a message.", blank=True + ) + + +class UngelichTextSection(CMSPlugin): + menu_text = models.CharField(max_length=100, default="", blank=True) + title = models.CharField(max_length=200) + description = HTMLField() + + +class Service(CMSPlugin): + menu_text = models.CharField(max_length=100, default="", blank=True) + title = models.CharField(max_length=200) + sub_title = models.CharField(max_length=200) + + def __str__(self): + return self.title + + +class ServiceItem(CMSPlugin): + image = FilerImageField( + null=True, + blank=True, + related_name="service_item_image", + on_delete=models.SET_NULL + ) + title = models.CharField(max_length=200) + description = HTMLField() + + def __str__(self): + return self.title + + +class About(Service): + pass + + +class AboutItem(UngelichPicture): + inverted = models.BooleanField(default=False) + link_url = models.URLField(max_length=300, default="", blank=True) + + def __str__(self): + alignment = "Right" if self.inverted else "Left" + return "{alignment} - {title}".format( + alignment=alignment, title=self.title + ) diff --git a/ungleich_page/static/ungleich_page/css/cms.css b/ungleich_page/static/ungleich_page/css/cms.css new file mode 100644 index 00000000..ac2a7526 --- /dev/null +++ b/ungleich_page/static/ungleich_page/css/cms.css @@ -0,0 +1,12 @@ +.lead, .split-description.wow.fadeInUp p{ + font-family: "Raleway" , "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 21px; + color: #3a3a3a; + font-weight: 300 !important; +} + +@media(min-width: 768px) { + .custom-padding-bottom{ + padding-bottom: 0; + } +} diff --git a/ungleich_page/templates/ungleich_page/glasfaser/_about_item.html b/ungleich_page/templates/ungleich_page/glasfaser/_about_item.html new file mode 100644 index 00000000..0ccdff9a --- /dev/null +++ b/ungleich_page/templates/ungleich_page/glasfaser/_about_item.html @@ -0,0 +1,12 @@ +
{{instance.email}}
+{{instance.address}}
+{{instance.country}}
++ {% trans "Your message was successfully sent to our team." %} +
+{{instance.description}}
+{{instance.description}}
+