add sections overview plugin
This commit is contained in:
parent
9dcec2fa62
commit
9623f7105b
4 changed files with 114 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue