From 9beacd6f6a5d7430b40d2283ccd1a3d702992e8b Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 2 Dec 2017 08:45:31 +0100 Subject: [PATCH 1/2] Introduce ungleich Header with Background and Image Slider plugin --- ungleich_page/cms_plugins.py | 39 ++++++++++++++++- ...eichheaderwithbackgroundimageslideritem.py | 43 +++++++++++++++++++ ungleich_page/models.py | 21 +++++++++ ...der_with_background_image_slider_item.html | 4 ++ .../header_with_background_image_slider.html | 31 +++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 ungleich_page/migrations/0016_ungleichheaderwithbackgroundimageslider_ungleichheaderwithbackgroundimageslideritem.py create mode 100644 ungleich_page/templates/ungleich_page/ungleich/_header_with_background_image_slider_item.html create mode 100644 ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py index c8dbe735..766ccb8c 100644 --- a/ungleich_page/cms_plugins.py +++ b/ungleich_page/cms_plugins.py @@ -5,7 +5,9 @@ from .models import ( UngelichContactUsSection, UngelichTextSection, Service, ServiceItem, About, AboutItem, SectionWithImage, UngleichServiceItem, UngleichHeader, UngleichHeaderItem, UngleichProductItem, UngleichProduct, UngleichCustomer, - UngleichCustomerItem, UngleichHTMLOnly, UngleichSimpleHeader + UngleichCustomerItem, UngleichHTMLOnly, UngleichSimpleHeader, + UngleichHeaderWithBackgroundImageSlider, + UngleichHeaderWithBackgroundImageSliderItem ) @@ -224,6 +226,41 @@ class UngleichHeaderItemPlugin(CMSPluginBase): return context +@plugin_pool.register_plugin +class UngleichHeaderBackgroundImageAndTextSliderPlugin(CMSPluginBase): + name = "ungleich Header with Background and Image Slider Plugin" + model = UngleichHeaderWithBackgroundImageSlider + render_template = ( + 'ungleich_page/ungleich/header_with_background_image_slider.html' + ) + cache = False + allow_children = True + child_classes = ['UngleichHeaderBackgroundImageAndTextItemPlugin'] + + def render(self, context, instance, placeholder): + context['instance'] = instance + return context + + +@plugin_pool.register_plugin +class UngleichHeaderBackgroundImageAndTextItemPlugin(CMSPluginBase): + name = "ungleich Header with Background and Image and Text Item Plugin" + model = UngleichHeaderWithBackgroundImageSliderItem + render_template = ( + 'ungleich_page/ungleich/_header_with_background_image_slider_item.html' + ) + cache = False + require_parent = True + parent_classes = ['UngleichHeaderBackgroundImageAndTextSliderPlugin'] + + def render(self, context, instance, placeholder): + context = super( + UngleichHeaderBackgroundImageAndTextItemPlugin, self + ).render(context, instance, placeholder) + context['instance'] = instance + return context + + @plugin_pool.register_plugin class UngleichProductsPlugin(CMSPluginBase): name = "ungleich Products Plugin" diff --git a/ungleich_page/migrations/0016_ungleichheaderwithbackgroundimageslider_ungleichheaderwithbackgroundimageslideritem.py b/ungleich_page/migrations/0016_ungleichheaderwithbackgroundimageslider_ungleichheaderwithbackgroundimageslideritem.py new file mode 100644 index 00000000..acbff47b --- /dev/null +++ b/ungleich_page/migrations/0016_ungleichheaderwithbackgroundimageslider_ungleichheaderwithbackgroundimageslideritem.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-12-02 07:30 +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): + + dependencies = [ + ('filer', '0004_auto_20160328_1434'), + ('cms', '0014_auto_20160404_1908'), + ('ungleich_page', '0015_ungleichsimpleheader'), + ] + + operations = [ + migrations.CreateModel( + name='UngleichHeaderWithBackgroundImageSlider', + 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')), + ('carousel_data_interval', models.IntegerField(default=2000)), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + migrations.CreateModel( + name='UngleichHeaderWithBackgroundImageSliderItem', + 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')), + ('description', djangocms_text_ckeditor.fields.HTMLField(default='
We Design, Configure & Maintain
Your Linux Infrastructure

Ruby on Rails, Django, Java, Webserver, Mailserver, any infrastructure that needs to configured, we provide comprehensive solutions. Amazon, rackspace or bare metal servers, we configure for you.

Learn More

')), + ('background_image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ungleich_header_slider_item_image', to='filer.Image')), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/ungleich_page/models.py b/ungleich_page/models.py index aec629ee..5c226ad4 100644 --- a/ungleich_page/models.py +++ b/ungleich_page/models.py @@ -124,6 +124,27 @@ class UngleichHeader(CMSPlugin): carousel_data_interval = models.IntegerField(default=5000) +class UngleichHeaderWithBackgroundImageSliderItem(CMSPlugin): + background_image = FilerImageField( + null=True, blank=True, + related_name="ungleich_header_slider_item_image", + on_delete=models.SET_NULL + ) + description = HTMLField( + default='
We Design, Configure & Maintain ' + '
Your Linux Infrastructure

' + 'Ruby on Rails, Django, Java, Webserver, Mailserver, any ' + 'infrastructure that needs to configured, we provide ' + 'comprehensive solutions. Amazon, rackspace or bare metal ' + 'servers, we configure for you.

Learn More

' + ) + + +class UngleichHeaderWithBackgroundImageSlider(CMSPlugin): + carousel_data_interval = models.IntegerField(default=2000) + + class UngleichHeaderItem(CMSPlugin): image = FilerImageField( null=True, diff --git a/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_image_slider_item.html b/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_image_slider_item.html new file mode 100644 index 00000000..063a0a7b --- /dev/null +++ b/ungleich_page/templates/ungleich_page/ungleich/_header_with_background_image_slider_item.html @@ -0,0 +1,4 @@ +
+
+ {{ instance.description }} +
\ No newline at end of file diff --git a/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html b/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html new file mode 100644 index 00000000..b211aef9 --- /dev/null +++ b/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html @@ -0,0 +1,31 @@ +{% load cms_tags %} +
+ +
\ No newline at end of file From f7c606906ce70e8939581e0a388d04feefef4ddd Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 2 Dec 2017 08:54:07 +0100 Subject: [PATCH 2/2] Rearrange code --- .../header_with_background_image_slider.html | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html b/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html index b211aef9..a3ee0d37 100644 --- a/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html +++ b/ungleich_page/templates/ungleich_page/ungleich/header_with_background_image_slider.html @@ -2,13 +2,13 @@
- {% if instance.child_plugin_instances|length > 1 %} - - - Previous - - - - Next - - {% endif %} + {% if instance.child_plugin_instances|length > 1 %} + + + Previous + + + + Next + + {% endif %}
\ No newline at end of file