Even better permissions. Seems that they get swapped automatically!

main
Jaap Joris Vens 2020-03-20 14:32:53 +01:00
rodzic d5bbfb67cf
commit 09f03b6866
2 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -29,7 +29,7 @@
{% for p in pages %}
<li><a href="{% if p.slug %}{% url 'cms:page' p.slug %}{% else %}{% url 'cms:page' %}{% endif %}" {% if p.pk == page.pk %}class="current"{% endif %}>{{p.title}}</a></li>
{% endfor %}
{% if user.is_staff %}
{% if perms.cms_page_create %}
<li><a class="edit" href="{% url 'cms:createpage' %}">+ {% trans 'new page' %}</a></li>
{% endif %}
</ul>

Wyświetl plik

@ -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))