Add CMS toolbar menu for govplan
This commit is contained in:
parent
0322b3b28e
commit
c9ffda4ecb
2 changed files with 30 additions and 0 deletions
28
froide_govplan/cms_toolbars.py
Normal file
28
froide_govplan/cms_toolbars.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from cms.toolbar_base import CMSToolbar
|
||||||
|
from cms.toolbar_pool import toolbar_pool
|
||||||
|
|
||||||
|
|
||||||
|
class GovPlanToolbar(CMSToolbar):
|
||||||
|
def populate(self):
|
||||||
|
if not hasattr(self.request, "govplan"):
|
||||||
|
return
|
||||||
|
|
||||||
|
menu = self.toolbar.get_or_create_menu("govplan-menu", _("GovPlan"))
|
||||||
|
govplan = self.request.govplan
|
||||||
|
url = reverse(
|
||||||
|
"govplan:admin:froide_govplan_governmentplan_change",
|
||||||
|
args=(govplan.pk,),
|
||||||
|
current_app="govplan",
|
||||||
|
)
|
||||||
|
menu.add_modal_item(_("Edit government plan"), url=url)
|
||||||
|
url = reverse(
|
||||||
|
"govplan:admin:froide_govplan_governmentplanupdate_add",
|
||||||
|
current_app="govplan",
|
||||||
|
)
|
||||||
|
menu.add_modal_item(_("Add update"), url=url)
|
||||||
|
|
||||||
|
|
||||||
|
toolbar_pool.register(GovPlanToolbar)
|
||||||
|
|
@ -52,6 +52,8 @@ class GovPlanDetailView(GovernmentMixin, DetailView):
|
||||||
"-timestamp"
|
"-timestamp"
|
||||||
)
|
)
|
||||||
context["section"] = self.get_section()
|
context["section"] = self.get_section()
|
||||||
|
# For CMS toolbar
|
||||||
|
self.request.govplan = self.object
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue