2017-10-17 07:30:52 +00:00
|
|
|
from cms.plugin_base import CMSPluginBase
|
|
|
|
from cms.plugin_pool import plugin_pool
|
2017-10-17 13:52:30 +00:00
|
|
|
|
2017-10-17 15:47:40 +00:00
|
|
|
from .models import (
|
2017-10-18 22:30:07 +00:00
|
|
|
UngelichContactUsSection, UngelichTextSection, Service, ServiceItem,
|
|
|
|
About, AboutItem, SectionWithImage
|
2017-10-17 15:47:40 +00:00
|
|
|
)
|
2017-10-17 07:30:52 +00:00
|
|
|
|
|
|
|
|
2017-10-19 11:45:28 +00:00
|
|
|
def get_section_id(plugin_instance, default):
|
|
|
|
"""
|
|
|
|
A helper function to get the section id from a given menu text
|
|
|
|
:param plugin_instance:
|
|
|
|
:param default: The default section id to return in case a section id
|
|
|
|
is not found
|
|
|
|
:return: The section id for the plugin_instance
|
|
|
|
"""
|
|
|
|
section_id = default
|
|
|
|
if hasattr(plugin_instance, 'menu_text'):
|
|
|
|
menu_words = plugin_instance.menu_text.split()
|
|
|
|
if len(menu_words) > 0:
|
|
|
|
section_id = menu_words[0]
|
|
|
|
return section_id
|
|
|
|
|
|
|
|
|
2017-10-17 07:30:52 +00:00
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class SectionWithImagePlugin(CMSPluginBase):
|
2017-10-18 22:30:07 +00:00
|
|
|
model = SectionWithImage
|
2017-10-17 07:30:52 +00:00
|
|
|
render_template = "ungleich_page/glasfaser/section_with_image.html"
|
|
|
|
cache = False
|
|
|
|
|
2017-10-17 13:52:30 +00:00
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context.update({
|
|
|
|
'image': instance.image,
|
|
|
|
'object': instance,
|
|
|
|
'placeholder': placeholder
|
|
|
|
})
|
|
|
|
return context
|
|
|
|
|
2017-10-17 07:30:52 +00:00
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class SectionContact(CMSPluginBase):
|
2017-10-17 14:25:01 +00:00
|
|
|
model = UngelichContactUsSection
|
2017-10-17 07:30:52 +00:00
|
|
|
render_template = "ungleich_page/glasfaser/section_contact.html"
|
|
|
|
cache = False
|
2017-10-17 15:47:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class SectionTextParagraphDCL(CMSPluginBase):
|
|
|
|
model = UngelichTextSection
|
|
|
|
render_template = "ungleich_page/glasfaser/section_text_dcl.html"
|
|
|
|
cache = False
|
|
|
|
|
2017-10-19 11:45:28 +00:00
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context = super(SectionTextParagraphDCL, self).render(
|
|
|
|
context, instance, placeholder
|
|
|
|
)
|
|
|
|
context['instance'] = instance
|
|
|
|
context['section_id'] = get_section_id(instance, 'your')
|
|
|
|
return context
|
|
|
|
|
2017-10-17 15:47:40 +00:00
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class SectionTextParagraphGlasfaser(CMSPluginBase):
|
|
|
|
model = UngelichTextSection
|
|
|
|
render_template = "ungleich_page/glasfaser/section_text_glasfaser.html"
|
|
|
|
cache = False
|
2017-10-18 07:10:50 +00:00
|
|
|
|
2017-10-19 11:45:28 +00:00
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context = super(SectionTextParagraphGlasfaser, self).render(
|
|
|
|
context, instance, placeholder
|
|
|
|
)
|
|
|
|
context['instance'] = instance
|
|
|
|
context['section_id'] = get_section_id(instance, 'our')
|
|
|
|
return context
|
|
|
|
|
2017-10-18 07:10:50 +00:00
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class GlasfaserServicesPlugin(CMSPluginBase):
|
2017-10-18 13:51:47 +00:00
|
|
|
name = "Glasfaser Services Plugin"
|
|
|
|
model = Service
|
2017-10-18 07:10:50 +00:00
|
|
|
render_template = "ungleich_page/glasfaser/section_services.html"
|
|
|
|
cache = False
|
2017-10-18 13:51:47 +00:00
|
|
|
allow_children = True
|
|
|
|
child_classes = ['GlasfaserServicesItemPlugin']
|
2017-10-18 07:10:50 +00:00
|
|
|
|
|
|
|
def render(self, context, instance, placeholder):
|
2017-10-18 13:51:47 +00:00
|
|
|
context['service_instance'] = instance
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class GlasfaserServicesItemPlugin(CMSPluginBase):
|
|
|
|
name = "Glasfaser Service Item Plugin"
|
|
|
|
model = ServiceItem
|
2017-10-18 13:58:50 +00:00
|
|
|
render_template = "ungleich_page/glasfaser/_services_item.html"
|
2017-10-18 13:51:47 +00:00
|
|
|
cache = False
|
|
|
|
require_parent = True
|
|
|
|
parent_classes = ['GlasfaserServicesPlugin']
|
|
|
|
|
|
|
|
def render(self, context, instance, placeholder):
|
2017-10-18 18:24:50 +00:00
|
|
|
context = super(GlasfaserServicesItemPlugin, self).render(
|
|
|
|
context, instance, placeholder
|
|
|
|
)
|
2017-10-18 13:51:47 +00:00
|
|
|
context['instance'] = instance
|
2017-10-18 07:10:50 +00:00
|
|
|
return context
|
2017-10-18 14:56:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class GlasfaserAboutPlugin(CMSPluginBase):
|
|
|
|
name = "Glasfaser About Plugin"
|
|
|
|
model = About
|
|
|
|
render_template = "ungleich_page/glasfaser/section_about.html"
|
|
|
|
cache = False
|
|
|
|
allow_children = True
|
|
|
|
child_classes = ['GlasfaserAboutItemPlugin']
|
|
|
|
|
|
|
|
def render(self, context, instance, placeholder):
|
|
|
|
context['about_instance'] = instance
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
@plugin_pool.register_plugin
|
|
|
|
class GlasfaserAboutItemPlugin(CMSPluginBase):
|
|
|
|
name = "Glasfaser About Item Plugin"
|
|
|
|
model = AboutItem
|
|
|
|
render_template = "ungleich_page/glasfaser/_about_item.html"
|
|
|
|
cache = False
|
|
|
|
require_parent = True
|
|
|
|
parent_classes = ['GlasfaserAboutPlugin']
|
|
|
|
|
|
|
|
def render(self, context, instance, placeholder):
|
2017-10-18 18:24:50 +00:00
|
|
|
context = super(GlasfaserAboutItemPlugin, self).render(
|
|
|
|
context, instance, placeholder
|
|
|
|
)
|
2017-10-18 14:56:41 +00:00
|
|
|
context['instance'] = instance
|
|
|
|
return context
|