From 379f68ed4b4b18c87dafc19944938b3c04c9d7e7 Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Wed, 16 Jan 2008 04:52:30 +0000 Subject: [PATCH] * Add ability to place a ticket on hold, stopping automatic escalation. --- models.py | 8 ++++++++ scripts/escalate_tickets.py | 2 +- templates/helpdesk/ticket.html | 2 +- urls.py | 7 +++++++ views.py | 28 ++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/models.py b/models.py index 3d675d30..21f845ba 100644 --- a/models.py +++ b/models.py @@ -125,6 +125,8 @@ class Ticket(models.Model): assigned_to = models.ForeignKey(User, related_name='assigned_to', blank=True, null=True) status = models.IntegerField(choices=STATUS_CHOICES, default=OPEN_STATUS) + on_hold = models.BooleanField(blank=True, null=True) + description = models.TextField(blank=True, null=True) resolution = models.TextField(blank=True, null=True) @@ -159,6 +161,12 @@ class Ticket(models.Model): return "%s/helpdesk/priorities/priority%s.png" % (settings.MEDIA_URL, self.priority) get_priority_img = property(_get_priority_img) + def _get_status(self): + held_msg = '' + if self.on_hold: held_msg = ' (Held)' + return '%s%s' % (self.get_status_display, held_msg) + get_status = property(_get_status) + def _get_ticket_url(self): from django.contrib.sites.models import Site from django.core.urlresolvers import reverse diff --git a/scripts/escalate_tickets.py b/scripts/escalate_tickets.py index 899bd105..3997c474 100644 --- a/scripts/escalate_tickets.py +++ b/scripts/escalate_tickets.py @@ -44,7 +44,7 @@ def escalate_tickets(): q.last_escalation = datetime.now() q.save() - for t in q.ticket_set.filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)).exclude(priority=1): + for t in q.ticket_set.filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)).exclude(priority=1).exclude(on_hold=True): t.priority -= 1 t.save() diff --git a/templates/helpdesk/ticket.html b/templates/helpdesk/ticket.html index 2fceefaa..c3c6e5c4 100644 --- a/templates/helpdesk/ticket.html +++ b/templates/helpdesk/ticket.html @@ -25,7 +25,7 @@ {% block helpdesk_body %} - + diff --git a/urls.py b/urls.py index 8a97036e..4b4af6a7 100644 --- a/urls.py +++ b/urls.py @@ -53,7 +53,14 @@ urlpatterns = patterns('helpdesk.views', url(r'^tickets/(?P[0-9]+)/delete/$', 'delete_ticket', name='helpdesk_delete'), + + url(r'^tickets/(?P[0-9]+)/hold/$', + 'hold_ticket', + name='helpdesk_hold'), + url(r'^tickets/(?P[0-9]+)/unhold/$', + 'unhold_ticket', + name='helpdesk_unhold'), url(r'^raw/(?P\w+)/$', 'raw_details', diff --git a/views.py b/views.py index f0e5af7c..b76be6ef 100644 --- a/views.py +++ b/views.py @@ -303,3 +303,31 @@ def public_view(request): 'email': email, 'error_message': error_message, })) + +def hold_ticket(request, ticket_id, unhold=False): + ticket = get_object_or_404(Ticket, id=ticket_id) + + if unhold: + ticket.on_hold = False + title = 'Ticket placed on hold' + else: + ticket.on_hold = True + title = 'Ticket taken off hold' + + f = FollowUp( + ticket = ticket, + user = request.user, + title = title, + date = datetime.now(), + ) + f.save() + + ticket.save() + + return HttpResponseRedirect(ticket.get_absolute_url()) +hold_ticket = login_required(hold_ticket) + +def unhold_ticket(request, ticket_id): + return hold_ticket(request, ticket_id, unhold=True) +unhold_ticket = login_required(unhold_ticket) +
{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status_display }}]EditDelete
{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]EditDelete{% if ticket.on_hold %}Unhold{% else %}Hold{% endif %}
Queue: {{ ticket.queue }}