Assign a bootstrap row color to tickets based on priority.

This commit is contained in:
Antoine Nguyen 2014-09-19 16:01:15 +02:00
parent 91628ab788
commit ad47087c8f
4 changed files with 17 additions and 13 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 == 4:
return "warning"
elif priority == 5:
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>
@ -18,4 +18,4 @@
<tr><td colspan='6'>{{ ticket_list_empty_message }}</td></tr>
{% endif %}{% endfor %}
</tbody>
</table>
</table>

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>
@ -18,4 +18,4 @@
<tr><td colspan='6'>{% trans "There are no unassigned tickets." %}</td></tr>
{% endfor %}
</tbody>
</table>
</table>

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>