add sections overview plugin

This commit is contained in:
krmax44 2022-03-14 14:02:00 +01:00
parent 9dcec2fa62
commit 9623f7105b
No known key found for this signature in database
GPG key ID: 5C499A4F4EC4EE03
4 changed files with 114 additions and 1 deletions

View file

@ -3,7 +3,12 @@ from django.utils.translation import gettext_lazy as _
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from .models import PLUGIN_TEMPLATES, GovernmentPlansCMSPlugin
from .models import (
PLUGIN_TEMPLATES,
GovernmentPlanSection,
GovernmentPlansCMSPlugin,
GovernmentPlanSectionsCMSPlugin,
)
@plugin_pool.register_plugin
@ -22,3 +27,24 @@ class GovernmentPlansPlugin(CMSPluginBase):
context["request"], published_only=False
)
return context
@plugin_pool.register_plugin
class GovernmentPlanSectionsPlugin(CMSPluginBase):
name = _("Government plan sections")
model = GovernmentPlanSectionsCMSPlugin
render_template = "froide_govplan/plugins/sections.html"
def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
if instance.government:
sections = GovernmentPlanSection.objects.filter(
government=instance.government
)
else:
sections = GovernmentPlanSection.objects.all()
context["sections"] = sections
return context