is_helpdesk_staff template filter (applied in navigation.html)

This commit is contained in:
Stefano Brentegani 2014-08-01 09:25:43 +02:00
parent 4ed8f11754
commit 8be4480a3f
2 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,4 @@
{% load i18n %}{% load url from future %}
{% load i18n helpdesk_staff %}{% load url from future %}
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
@ -11,7 +11,7 @@
</div>
<div class="collapse navbar-collapse" id="helpdesk-nav-collapse">
{% if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED and user.is_authenticated or user.is_staff %}
{% if helpdesk_settings.HELPDESK_NAVIGATION_ENABLED and user.is_authenticated or user|is_helpdesk_staff %}
<ul class="nav navbar-nav">
<li><a href='{% url 'helpdesk_dashboard' %}'><span class="glyphicon glyphicon-dashboard"></span> <span class="nav-text">{% trans "Dashboard" %}</span></a></li>
<li><a href='{% url 'helpdesk_list' %}'><span class="glyphicon glyphicon-tags"></span> <span class="nav-text">{% trans "Tickets" %}</span></a></li>

View File

@ -0,0 +1,22 @@
"""
django-helpdesk - A Django powered ticket tracker for small enterprise.
templatetags/helpdesk_staff.py - The is_helpdesk_staff template filter returns True if the user qualifies as Helpdesk staff.
"""
import logging
from django.template import Library
from django.db.models import Q
from helpdesk.decorators import is_helpdesk_staff
logger = logging.getLogger(__name__)
register = Library()
@register.filter(name='is_helpdesk_staff')
def helpdesk_staff(user):
try:
return is_helpdesk_staff(user)
except Exception, e:
logger.exception("'helpdesk_staff' template tag (django-helpdesk) crashed")