diff --git a/cms/templates/cms/base.html b/cms/templates/cms/base.html index d8df9e7..fbd3e5d 100644 --- a/cms/templates/cms/base.html +++ b/cms/templates/cms/base.html @@ -29,7 +29,7 @@ {% for p in pages %}
  • {{p.title}}
  • {% endfor %} - {% if user.is_staff %} + {% if perms.cms_page_create %}
  • + {% trans 'new page' %}
  • {% endif %} diff --git a/cms/templatetags/cms.py b/cms/templatetags/cms.py index 08c848a..6be1d41 100644 --- a/cms/templatetags/cms.py +++ b/cms/templatetags/cms.py @@ -14,12 +14,17 @@ class IncludeSectionNode(template.Node): def __init__(self, section): self.section = template.Variable(section) self.csrf_token = template.Variable('csrf_token') + self.perms = template.Variable('perms') super().__init__() def render(self, context): section = self.section.resolve(context) template_name = section.view.template_name csrf_token = self.csrf_token.resolve(context) - section.context.update({'csrf_token': csrf_token}) + perms = self.perms.resolve(context) + section.context.update({ + 'csrf_token': csrf_token, + 'perms': perms, + }) t = context.template.engine.get_template(template_name) return t.render(template.Context(section.context))