From 1e567ef6ad0e86ec1f438d2e6240944f74bfd9d9 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Nov 2017 00:19:07 +0100 Subject: [PATCH] Add ungleichproduct and ungleichproductitem plugins --- ungleich_page/cms_plugins.py | 36 +++++++++++++++++- ...011_ungleichproduct_ungleichproductitem.py | 38 +++++++++++++++++++ ungleich_page/models.py | 10 ++++- 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 ungleich_page/migrations/0011_ungleichproduct_ungleichproductitem.py diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py index 9d5cfda0..1b10375a 100644 --- a/ungleich_page/cms_plugins.py +++ b/ungleich_page/cms_plugins.py @@ -4,7 +4,7 @@ from cms.plugin_pool import plugin_pool from .models import ( UngelichContactUsSection, UngelichTextSection, Service, ServiceItem, About, AboutItem, SectionWithImage, UngleichServiceItem, UngleichHeader, - UngleichHeaderItem + UngleichHeaderItem, UngleichProductItem, UngleichProduct ) @@ -208,4 +208,36 @@ class UngleichHeaderItemPlugin(CMSPluginBase): context, instance, placeholder ) context['instance'] = instance - return context \ No newline at end of file + return context + + +@plugin_pool.register_plugin +class UngleichProductsPlugin(CMSPluginBase): + name = "ungleich Products Plugin" + model = UngleichProduct + render_template = "ungleich_page/ungleich/section_products.html" + cache = False + allow_children = True + child_classes = ['UngleichProductsItemPlugin'] + + def render(self, context, instance, placeholder): + context['product_instance'] = instance + context['section_id'] = get_section_id(instance, 'products') + return context + + +@plugin_pool.register_plugin +class UngleichProductsItemPlugin(CMSPluginBase): + name = "ungleich Product Item Plugin" + model = UngleichProductItem + render_template = "ungleich_page/ungleich/_products_item.html" + cache = False + require_parent = True + parent_classes = ['UngleichProductsPlugin'] + + def render(self, context, instance, placeholder): + context = super(UngleichProductsItemPlugin, self).render( + context, instance, placeholder + ) + context['instance'] = instance + return context diff --git a/ungleich_page/migrations/0011_ungleichproduct_ungleichproductitem.py b/ungleich_page/migrations/0011_ungleichproduct_ungleichproductitem.py new file mode 100644 index 00000000..c4984f5a --- /dev/null +++ b/ungleich_page/migrations/0011_ungleichproduct_ungleichproductitem.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-11-21 19:04 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ungleich_page', '0010_auto_20171119_1404'), + ] + + operations = [ + migrations.CreateModel( + name='UngleichProduct', + 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')), + ('section_class', models.CharField(blank=True, default='', max_length=100)), + ], + options={ + 'abstract': False, + }, + bases=('ungleich_page.service',), + ), + migrations.CreateModel( + name='UngleichProductItem', + fields=[ + ('serviceitem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ungleich_page.ServiceItem')), + ('url', models.URLField(blank=True, default='', max_length=300)), + ], + options={ + 'abstract': False, + }, + bases=('ungleich_page.serviceitem',), + ), + ] diff --git a/ungleich_page/models.py b/ungleich_page/models.py index d1e0199b..f936f23b 100644 --- a/ungleich_page/models.py +++ b/ungleich_page/models.py @@ -115,4 +115,12 @@ class UngleichHeaderItem(CMSPlugin): related_name="ungleich_header_item_image", on_delete=models.SET_NULL ) - description = HTMLField() \ No newline at end of file + description = HTMLField() + + +class UngleichProductItem(ServiceItem): + url = models.URLField(max_length=300, default="", blank=True) + + +class UngleichProduct(Service): + section_class = models.CharField(max_length=100, default="", blank=True) \ No newline at end of file