Merge pull request #261 from tonioo/master

Do not use the builtin staff_member_required decorator.
This commit is contained in:
Ross Poulton 2014-09-24 08:16:36 +10:00
commit 3093416d33
5 changed files with 18 additions and 17 deletions

View File

@ -372,13 +372,17 @@ class Ticket(models.Model):
return u"%shelpdesk/priorities/priority%s.png" % (settings.MEDIA_URL, self.priority)
get_priority_img = property(_get_priority_img)
def _get_priority_span(self):
def _get_priority_css_class(self):
"""
A HTML <span> providing a CSS_styled representation of the priority.
Return the boostrap class corresponding to the priority.
"""
from django.utils.safestring import mark_safe
return mark_safe(u"<span class='priority%s'>%s</span>" % (self.priority, self.priority))
get_priority_span = property(_get_priority_span)
if self.priority == 2:
return "warning"
elif self.priority == 1:
return "danger"
else:
return ""
get_priority_css_class = property(_get_priority_css_class)
def _get_status(self):
"""

View File

@ -6,9 +6,9 @@
</thead>
<tbody>
{% for ticket in ticket_list %}
<tr>
<tr class="{{ ticket.get_priority_css_class }}">
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
<td>{{ ticket.get_priority_span }}</td>
<td>{{ ticket.priority }}</td>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>

View File

@ -6,9 +6,9 @@
</thead>
<tbody>
{% for ticket in unassigned_tickets %}
<tr>
<tr class="{{ ticket.get_priority_css_class }}">
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
<td>{{ ticket.get_priority_span }}</td>
<td>{{ ticket.priority }}</td>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></td>

View File

@ -224,10 +224,10 @@ $(document).ready(function() {
</thead>
<tbody>
{% for ticket in tickets.object_list %}
<tr>
<tr class="{{ ticket.get_priority_css_class }}">
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
<td><input type='checkbox' name='ticket_id' value='{{ ticket.id }}' class='ticket_multi_select' /></td>
<td>{{ ticket.get_priority_span }}</td>
<td>{{ ticket.priority }}</td>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>

View File

@ -45,9 +45,6 @@ if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
# treat 'normal' users like 'staff'
staff_member_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active)
else:
try:
from django.contrib.admin.views.decorators import staff_member_required
except:
staff_member_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active and u.is_staff)