calculaotr plugin allows child promo and html plugin

This commit is contained in:
Arvind Tiwari 2018-03-23 03:22:29 +05:30
parent c3e83599a2
commit 3484b75d8b
3 changed files with 18 additions and 8 deletions

View file

@ -28,8 +28,8 @@ class DCLSectionPlugin(CMSPluginBase):
context = super(DCLSectionPlugin, self).render( context = super(DCLSectionPlugin, self).render(
context, instance, placeholder context, instance, placeholder
) )
context['children_to_right'] = [] context['children_to_side'] = []
context['children_to_left'] = [] context['children_to_content'] = []
if instance.child_plugin_instances is not None: if instance.child_plugin_instances is not None:
right_children = [ right_children = [
'DCLSectionImagePluginModel', 'DCLSectionImagePluginModel',
@ -37,9 +37,9 @@ class DCLSectionPlugin(CMSPluginBase):
] ]
for child in instance.child_plugin_instances: for child in instance.child_plugin_instances:
if child.__class__.__name__ in right_children: if child.__class__.__name__ in right_children:
context['children_to_right'].append(child) context['children_to_side'].append(child)
else: else:
context['children_to_left'].append(child) context['children_to_content'].append(child)
return context return context
@ -79,12 +79,22 @@ class DCLCalculatorPlugin(CMSPluginBase):
model = DCLSectionPluginModel model = DCLSectionPluginModel
render_template = "datacenterlight/cms/calculator.html" render_template = "datacenterlight/cms/calculator.html"
cache = False cache = False
allow_children = True
child_classes = [
'DCLSectionPromoPlugin', 'UngleichHTMLPlugin'
]
def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
context = super(DCLCalculatorPlugin, self).render( context = super(DCLCalculatorPlugin, self).render(
context, instance, placeholder context, instance, placeholder
) )
context['templates'] = VMTemplate.objects.all() 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 return context

View file

@ -12,9 +12,9 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if children_to_left|length %} {% if children_to_content|length %}
<div class="split-subsection"> <div class="split-subsection">
{% for plugin in children_to_left %} {% for plugin in children_to_content %}
{% render_plugin plugin %} {% render_plugin plugin %}
{% endfor %} {% endfor %}
</div> </div>

View file

@ -2,14 +2,14 @@
<section class="split-section {{ instance.get_extra_classes }}" id="{{ instance.html_id }}"> <section class="split-section {{ instance.get_extra_classes }}" id="{{ instance.html_id }}">
<div class="container"> <div class="container">
{% if children_to_right|length %} {% if children_to_side|length %}
<div class="row"> <div class="row">
<div class="col-sm-6 {% if instance.text_direction == 'right' %}col-sm-push-6{% endif %} split-text"> <div class="col-sm-6 {% if instance.text_direction == 'right' %}col-sm-push-6{% endif %} split-text">
{% include "datacenterlight/cms/includes/_section_split_content.html" %} {% include "datacenterlight/cms/includes/_section_split_content.html" %}
</div> </div>
<div class="col-sm-6 {% if instance.text_direction == 'right' %}col-sm-pull-6{% endif %} split-figure"> <div class="col-sm-6 {% if instance.text_direction == 'right' %}col-sm-pull-6{% endif %} split-figure">
<div class="section-figure"> <div class="section-figure">
{% for plugin in children_to_right %} {% for plugin in children_to_side %}
{% render_plugin plugin %} {% render_plugin plugin %}
{% endfor %} {% endfor %}
</div> </div>