oioioi.base.templatetags.check_perm

Module Contents

Classes

Functions

check_perm(parser, token)

A template tag to look up object permissions.

Attributes

oioioi.base.templatetags.check_perm.register[source]
class oioioi.base.templatetags.check_perm.CheckPermNode(perm, obj, var)[source]

Bases: django.template.Node

render(context)[source]

Return the node rendered as a string.

oioioi.base.templatetags.check_perm.check_perm(parser, token)[source]

A template tag to look up object permissions.

The current user is tested agains the given permission on the given object. Current user is taken from the template context, so the django.contrib.auth.context_processors.auth template context processor must be present in settings.TEMPLATE_CONTEXT_PROCESSORS.

Usage:

{% load check_perm %}

{% check_perm "some_permission" for some_object as variable %}
{% if variable %}
<p>This is shown if the user has some_permission on some_object.</p>
{% endif %}