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) return u"%shelpdesk/priorities/priority%s.png" % (settings.MEDIA_URL, self.priority)
get_priority_img = property(_get_priority_img) 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 if self.priority == 4:
return mark_safe(u"<span class='priority%s'>%s</span>" % (self.priority, self.priority)) return "warning"
get_priority_span = property(_get_priority_span) elif priority == 5:
return "danger"
else:
return ""
get_priority_css_class = property(_get_priority_css_class)
def _get_status(self): def _get_status(self):
""" """

View File

@ -6,9 +6,9 @@
</thead> </thead>
<tbody> <tbody>
{% for ticket in ticket_list %} {% for ticket in ticket_list %}
<tr> <tr class="{{ ticket.get_priority_css_class }}">
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th> <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> <th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td> <td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td> <td>{{ ticket.get_status }}</td>
@ -18,4 +18,4 @@
<tr><td colspan='6'>{{ ticket_list_empty_message }}</td></tr> <tr><td colspan='6'>{{ ticket_list_empty_message }}</td></tr>
{% endif %}{% endfor %} {% endif %}{% endfor %}
</tbody> </tbody>
</table> </table>

View File

@ -6,9 +6,9 @@
</thead> </thead>
<tbody> <tbody>
{% for ticket in unassigned_tickets %} {% for ticket in unassigned_tickets %}
<tr> <tr class="{{ ticket.get_priority_css_class }}">
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th> <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> <th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td> <td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></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> <tr><td colspan='6'>{% trans "There are no unassigned tickets." %}</td></tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View File

@ -224,10 +224,10 @@ $(document).ready(function() {
</thead> </thead>
<tbody> <tbody>
{% for ticket in tickets.object_list %} {% 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> <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><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> <th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td> <td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td> <td>{{ ticket.get_status }}</td>