add updates plugin

This commit is contained in:
krmax44 2022-03-17 16:38:47 +01:00
parent ca79e88c16
commit 03342fde2d
No known key found for this signature in database
GPG key ID: 5C499A4F4EC4EE03
6 changed files with 162 additions and 40 deletions

View file

@ -8,6 +8,7 @@ from .models import (
GovernmentPlansCMSPlugin,
GovernmentPlanSection,
GovernmentPlanSectionsCMSPlugin,
GovernmentPlanUpdatesCMSPlugin,
)
@ -51,3 +52,18 @@ class GovernmentPlanSectionsPlugin(CMSPluginBase):
context["sections"] = sections
return context
@plugin_pool.register_plugin
class GovernmentPlanUpdatesPlugin(CMSPluginBase):
name = _("Government plan updates")
model = GovernmentPlanUpdatesCMSPlugin
render_template = "froide_govplan/plugins/updates.html"
def render(self, context, instance, placeholder):
context = super().render(context, instance, placeholder)
context["updates"] = instance.get_updates(
context["request"], published_only=False
)
context["show_context"] = True
return context