From 91628ab788c185bcb742dbbde458be7ade30ac81 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 19 Sep 2014 15:15:42 +0200 Subject: [PATCH 1/4] Do not use the builtin staff_member_required decorator. Before 1.7, this decorator always redirects to the admin login page so the LOGIN_URL setting is useless. --- helpdesk/views/staff.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 73f88283..1aaae4cc 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -45,10 +45,7 @@ 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) + staff_member_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active and u.is_staff) superuser_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active and u.is_superuser) From ad47087c8fdd428c606197172407c435466b8578 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 19 Sep 2014 16:01:15 +0200 Subject: [PATCH 2/4] Assign a bootstrap row color to tickets based on priority. --- helpdesk/models.py | 14 +++++++++----- helpdesk/templates/helpdesk/include/tickets.html | 6 +++--- .../templates/helpdesk/include/unassigned.html | 6 +++--- helpdesk/templates/helpdesk/ticket_list.html | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index 76cb8047..4e9029c5 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -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 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"%s" % (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): """ diff --git a/helpdesk/templates/helpdesk/include/tickets.html b/helpdesk/templates/helpdesk/include/tickets.html index 410711ea..e83100cd 100644 --- a/helpdesk/templates/helpdesk/include/tickets.html +++ b/helpdesk/templates/helpdesk/include/tickets.html @@ -6,9 +6,9 @@ {% for ticket in ticket_list %} - + {{ ticket.ticket }} -{{ ticket.get_priority_span }} +{{ ticket.priority }} {{ ticket.title }} {{ ticket.queue }} {{ ticket.get_status }} @@ -18,4 +18,4 @@ {{ ticket_list_empty_message }} {% endif %}{% endfor %} - \ No newline at end of file + diff --git a/helpdesk/templates/helpdesk/include/unassigned.html b/helpdesk/templates/helpdesk/include/unassigned.html index 3053e31b..9942eb2b 100644 --- a/helpdesk/templates/helpdesk/include/unassigned.html +++ b/helpdesk/templates/helpdesk/include/unassigned.html @@ -6,9 +6,9 @@ {% for ticket in unassigned_tickets %} - + {{ ticket.ticket }} -{{ ticket.get_priority_span }} +{{ ticket.priority }} {{ ticket.title }} {{ ticket.queue }} {{ ticket.created|naturaltime }} @@ -18,4 +18,4 @@ {% trans "There are no unassigned tickets." %} {% endfor %} - \ No newline at end of file + diff --git a/helpdesk/templates/helpdesk/ticket_list.html b/helpdesk/templates/helpdesk/ticket_list.html index 521505f2..2341037a 100644 --- a/helpdesk/templates/helpdesk/ticket_list.html +++ b/helpdesk/templates/helpdesk/ticket_list.html @@ -224,10 +224,10 @@ $(document).ready(function() { {% for ticket in tickets.object_list %} - + {{ ticket.ticket }} -{{ ticket.get_priority_span }} +{{ ticket.priority }} {{ ticket.title }} {{ ticket.queue }} {{ ticket.get_status }} From 8095d30e8e64dd499dd3f4e407caf5dcdab74aad Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 19 Sep 2014 16:06:11 +0200 Subject: [PATCH 3/4] Remove unknown reference to priority. --- helpdesk/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index 4e9029c5..d13698ff 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -378,7 +378,7 @@ class Ticket(models.Model): """ if self.priority == 4: return "warning" - elif priority == 5: + elif self.priority == 5: return "danger" else: return "" From 58c2c818f44d2420f08ab9bad5f9eba371a7f677 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 22 Sep 2014 10:01:08 +0200 Subject: [PATCH 4/4] Use the right values to identify priorities. --- helpdesk/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index d13698ff..453b337d 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -376,9 +376,9 @@ class Ticket(models.Model): """ Return the boostrap class corresponding to the priority. """ - if self.priority == 4: + if self.priority == 2: return "warning" - elif self.priority == 5: + elif self.priority == 1: return "danger" else: return ""