From cf1f7d6141344847fd79a00f6705046aa39a3ad0 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Fri, 17 Nov 2017 17:37:05 +0100 Subject: [PATCH] Add UngleichServicesPlugin and UngleichServicesItemPlugin --- ungleich_page/cms_plugins.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ungleich_page/cms_plugins.py b/ungleich_page/cms_plugins.py index a5b10d5f..4c842093 100644 --- a/ungleich_page/cms_plugins.py +++ b/ungleich_page/cms_plugins.py @@ -3,7 +3,7 @@ from cms.plugin_pool import plugin_pool from .models import ( UngelichContactUsSection, UngelichTextSection, Service, ServiceItem, - About, AboutItem, SectionWithImage + About, AboutItem, SectionWithImage, UngleichServiceItem ) @@ -145,3 +145,35 @@ class GlasfaserAboutItemPlugin(CMSPluginBase): ) context['instance'] = instance return context + + +@plugin_pool.register_plugin +class UngleichServicesPlugin(CMSPluginBase): + name = "ungleich Services Plugin" + model = Service + render_template = "ungleich_page/ungleich/section_services.html" + cache = False + allow_children = True + child_classes = ['UngleichServicesItemPlugin'] + + 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 UngleichServicesItemPlugin(CMSPluginBase): + name = "ungleich Service Item Plugin" + model = UngleichServiceItem + render_template = "ungleich_page/ungleich/_services_item.html" + cache = False + require_parent = True + parent_classes = ['UngleichServicesPlugin'] + + def render(self, context, instance, placeholder): + context = super(UngleichServicesItemPlugin, self).render( + context, instance, placeholder + ) + context['instance'] = instance + return context \ No newline at end of file