From 3484b75d8b632d74d2dbc6dae60fc0feb3690e49 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Fri, 23 Mar 2018 03:22:29 +0530 Subject: [PATCH] calculaotr plugin allows child promo and html plugin --- datacenterlight/cms_plugins.py | 18 ++++++++++++++---- .../cms/includes/_section_split_content.html | 4 ++-- .../templates/datacenterlight/cms/section.html | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 40f3c098..a1a3833d 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -28,8 +28,8 @@ class DCLSectionPlugin(CMSPluginBase): context = super(DCLSectionPlugin, self).render( context, instance, placeholder ) - context['children_to_right'] = [] - context['children_to_left'] = [] + context['children_to_side'] = [] + context['children_to_content'] = [] if instance.child_plugin_instances is not None: right_children = [ 'DCLSectionImagePluginModel', @@ -37,9 +37,9 @@ class DCLSectionPlugin(CMSPluginBase): ] for child in instance.child_plugin_instances: if child.__class__.__name__ in right_children: - context['children_to_right'].append(child) + context['children_to_side'].append(child) else: - context['children_to_left'].append(child) + context['children_to_content'].append(child) return context @@ -79,12 +79,22 @@ class DCLCalculatorPlugin(CMSPluginBase): model = DCLSectionPluginModel render_template = "datacenterlight/cms/calculator.html" cache = False + allow_children = True + child_classes = [ + 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin' + ] def render(self, context, instance, placeholder): context = super(DCLCalculatorPlugin, self).render( context, instance, placeholder ) context['templates'] = VMTemplate.objects.all() + context['children_to_side'] = [] + context['children_to_content'] = [] + if instance.child_plugin_instances is not None: + context['children_to_content'].extend( + instance.child_plugin_instances + ) return context diff --git a/datacenterlight/templates/datacenterlight/cms/includes/_section_split_content.html b/datacenterlight/templates/datacenterlight/cms/includes/_section_split_content.html index 9323b52f..0f41740f 100644 --- a/datacenterlight/templates/datacenterlight/cms/includes/_section_split_content.html +++ b/datacenterlight/templates/datacenterlight/cms/includes/_section_split_content.html @@ -12,9 +12,9 @@ {% endif %} -{% if children_to_left|length %} +{% if children_to_content|length %}
- {% for plugin in children_to_left %} + {% for plugin in children_to_content %} {% render_plugin plugin %} {% endfor %}
diff --git a/datacenterlight/templates/datacenterlight/cms/section.html b/datacenterlight/templates/datacenterlight/cms/section.html index 7500ceb3..5a420a99 100644 --- a/datacenterlight/templates/datacenterlight/cms/section.html +++ b/datacenterlight/templates/datacenterlight/cms/section.html @@ -2,14 +2,14 @@
- {% if children_to_right|length %} + {% if children_to_side|length %}
{% include "datacenterlight/cms/includes/_section_split_content.html" %}
- {% for plugin in children_to_right %} + {% for plugin in children_to_side %} {% render_plugin plugin %} {% endfor %}