6. Template Permissions¶
6.1. Overview¶
There are two helpers for checking a users permission against roles from within a template, this makes it easy to include functionality into the template for those users that have a certain role and hide it from those without that role.
6.3. Usage - Filter¶
- class portal.utils.templatetags.permissionrequired.has_role(user, roles)¶
Returns a boolean if the user has the give role, or comma-separated list of roles. Can be used in conjunction with the standard if tag.
Usage:
{% if user|has_role:"Friends" %} ... {% endif %}
or:
{% if user|has_role:"Friends,Enemies" %} ... {% endif %}
- class portal.utils.templatetags.permissionrequired.get_logged_in_roles(user)¶
Returns users logged in roles.
- Args:
User