From 824fd1a6b523031fa31de3d51f801b0d4beb2dc4 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 24 Nov 2017 20:29:26 +0100 Subject: [PATCH] Add UngleichHeaderWithTextAndImagePlugin --- ungleich_page/cms_plugins.py | 14 +++++++- .../migrations/0015_ungleichsimpleheader.py | 33 +++++++++++++++++++ ungleich_page/models.py | 16 +++++++++ .../ungleich_page/ungleich/header.html | 15 +++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 ungleich_page/migrations/0015_ungleichsimpleheader.py create mode 100644 ungleich_page/templates/ungleich_page/ungleich/header.html diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py index 02129a85..c8dbe735 100644 --- a/ungleich_page/cms_plugins.py +++ b/ungleich_page/cms_plugins.py @@ -5,7 +5,7 @@ from .models import ( UngelichContactUsSection, UngelichTextSection, Service, ServiceItem, About, AboutItem, SectionWithImage, UngleichServiceItem, UngleichHeader, UngleichHeaderItem, UngleichProductItem, UngleichProduct, UngleichCustomer, - UngleichCustomerItem, UngleichHTMLOnly + UngleichCustomerItem, UngleichHTMLOnly, UngleichSimpleHeader ) @@ -181,6 +181,18 @@ class UngleichServicesItemPlugin(CMSPluginBase): return context +@plugin_pool.register_plugin +class UngleichHeaderWithTextAndImagePlugin(CMSPluginBase): + name = "ungleich Header with Text and Image Plugin" + model = UngleichSimpleHeader + render_template = "ungleich_page/ungleich/header.html" + cache = False + + def render(self, context, instance, placeholder): + context['instance'] = instance + return context + + @plugin_pool.register_plugin class UngleichHeaderWithTextAndImageSliderPlugin(CMSPluginBase): name = "ungleich Header with Text and Image Slider Plugin" diff --git a/ungleich_page/migrations/0015_ungleichsimpleheader.py b/ungleich_page/migrations/0015_ungleichsimpleheader.py new file mode 100644 index 00000000..c43d0c79 --- /dev/null +++ b/ungleich_page/migrations/0015_ungleichsimpleheader.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-11-24 19:12 +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', '0014_ungleichhtmlonly_name'), + ] + + operations = [ + migrations.CreateModel( + name='UngleichSimpleHeader', + 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')), + ('text', djangocms_text_ckeditor.fields.HTMLField()), + ('background_image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ungleich_simple_header_background_image', to='filer.Image')), + ('image', filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ungleich_simple_header_image', to='filer.Image')), + ], + options={ + 'abstract': False, + }, + bases=('cms.cmsplugin',), + ), + ] diff --git a/ungleich_page/models.py b/ungleich_page/models.py index 706e1682..aec629ee 100644 --- a/ungleich_page/models.py +++ b/ungleich_page/models.py @@ -98,6 +98,22 @@ class UngleichServiceItem(ServiceItem): ) +class UngleichSimpleHeader(CMSPlugin): + background_image = FilerImageField( + null=True, + blank=True, + related_name="ungleich_simple_header_background_image", + on_delete=models.SET_NULL + ) + image = FilerImageField( + null=True, + blank=True, + related_name="ungleich_simple_header_image", + on_delete=models.SET_NULL + ) + text = HTMLField() + + class UngleichHeader(CMSPlugin): background_image = FilerImageField( null=True, diff --git a/ungleich_page/templates/ungleich_page/ungleich/header.html b/ungleich_page/templates/ungleich_page/ungleich/header.html new file mode 100644 index 00000000..77c7ffdf --- /dev/null +++ b/ungleich_page/templates/ungleich_page/ungleich/header.html @@ -0,0 +1,15 @@ +{% load cms_tags %} + +
+
+
+ +


+
+ + {{ instance.text }} + +
+
+
+