Initial commit
This commit is contained in:
commit
19170142c3
20 changed files with 894 additions and 0 deletions
24
froide_govplan/cms_plugins.py
Normal file
24
froide_govplan/cms_plugins.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
||||
|
||||
@plugin_pool.register_plugin
|
||||
class GovernmentPlansPlugin(CMSPluginBase):
|
||||
name = _("Government plans")
|
||||
model = GovernmentPlansCMSPlugin
|
||||
filter_horizontal = ("categories",)
|
||||
cache = True
|
||||
|
||||
def get_render_template(self, context, instance, placeholder):
|
||||
return instance.template or PLUGIN_TEMPLATES[0][0]
|
||||
|
||||
def render(self, context, instance, placeholder):
|
||||
context = super().render(context, instance, placeholder)
|
||||
context["object_list"] = instance.get_plans(
|
||||
context["request"], published_only=False
|
||||
)
|
||||
return context
|
||||
Loading…
Add table
Add a link
Reference in a new issue