* Add 'modified' field to tickets - updated when the ticket or a followup is saved

* Added 'Priority' ot tickets along with update code.
This commit is contained in:
Ross Poulton 2008-01-10 00:28:45 +00:00
parent 5052d40876
commit 8aae8564ba
5 changed files with 57 additions and 7 deletions

View File

@ -99,9 +99,18 @@ class Ticket(models.Model):
(CLOSED_STATUS, 'Closed'),
)
PRIORITY_CHOICES = (
(1, '1 (Critical)'),
(2, '2 (High)'),
(3, '3 (Normal)'),
(4, '4 (Low)'),
(5, '5 (Very Low)'),
)
title = models.CharField(maxlength=200)
queue = models.ForeignKey(Queue)
created = models.DateTimeField(auto_now_add=True)
created = models.DateTimeField(blank=True)
modified = models.DateTimeField(blank=True)
submitter_email = models.EmailField(blank=True, null=True, help_text='The submitter will receive an email for all public follow-ups left for this task.')
assigned_to = models.ForeignKey(User, related_name='assigned_to', blank=True, null=True)
status = models.IntegerField(choices=STATUS_CHOICES, default=OPEN_STATUS)
@ -109,6 +118,8 @@ class Ticket(models.Model):
description = models.TextField(blank=True, null=True)
resolution = models.TextField(blank=True, null=True)
priority = models.IntegerField(choices=PRIORITY_CHOICES, default=3, blank=3)
def _get_assigned_to(self):
""" Custom property to allow us to easily print 'Unassigned' if a
ticket has no owner, or the users name if it's assigned. If the user
@ -148,6 +159,11 @@ class Ticket(models.Model):
if not self.id:
# This is a new ticket as no ID yet exists.
self.created = datetime.now()
if not self.priority:
self.priority = 3
self.modified = datetime.now()
super(Ticket, self).save()
@ -181,6 +197,13 @@ class FollowUp(models.Model):
def __unicode__(self):
return '%s' % self.title
def save(self):
t = self.ticket
t.modified = datetime.now()
t.save()
super(FollowUp, self).save()
class TicketChange(models.Model):
""" For each FollowUp, any changes to the parent ticket (eg Title, Priority,
etc) are tracked here for display purposes.

View File

@ -93,6 +93,16 @@ def ticket_from_message(message, queue):
except:
ticket = None
priority = 3
smtp_priority = message.get('priority', '')
smtp_importance = message.get('importance', '')
high_priority_types = ('high', 'important', '1', 'urgent')
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
priority = 2
if ticket == None:
t = Ticket(
title=subject,
@ -100,6 +110,7 @@ def ticket_from_message(message, queue):
submitter_email=sender_email,
created=now,
description=body,
priority=priority,
)
t.save()

View File

@ -23,11 +23,11 @@ $(document).ready(function() {
<tr class='row_columnheads'><th>#</th><th>Title</th><th>Queue</th><th>Status</th><th>Last Update</th></tr>
{% for ticket in user_tickets %}
<tr class='row_{% cycle odd,even %} row_hover'>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.id }}</a></th>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status_display }}</td>
<td>{{ ticket.last_update|timesince }}</td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|timesince }}</span></td>
</tr>
{% endfor %}
</table>
@ -37,7 +37,7 @@ $(document).ready(function() {
<tr class='row_columnheads'><th>#</th><th>Title</th><th>Queue</th><th>Created</th><th>&nbsp;</th></tr>
{% for ticket in unassigned_tickets %}
<tr class='row_{% cycle odd,even %} row_hover'>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.id }}</a></th>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.ticket }}</a></th>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|timesince }} ago</span></td>

View File

@ -36,16 +36,21 @@
</tr>
<tr class='row_even'>
<th>Priority</th>
<td>{{ ticket.get_priority_display }}</td>
</tr>
<tr class='row_odd'>
<th colspan='2'>Description</th>
</tr>
<tr class='row_odd'>
<tr class='row_even'>
<td colspan='2'>{{ ticket.description }}</td>
</tr>
{% if ticket.resolution %}<tr class='row_even'>
{% if ticket.resolution %}<tr class='row_odd'>
<th colspan='2'>Resolution{% ifequal ticket.get_status_display "Resolved" %} [<a href='?close'>Accept &amp; Close</a>]{% endifequal %}</th>
</tr>
<tr class='row_odd'>
<tr class='row_even'>
<td colspan='2'>{{ ticket.resolution }}</td>
</tr>{% endif %}
@ -102,6 +107,9 @@ Changed {{ change.field }} from {{ change.old_value }} to {{ change.new_value }}
<label for='id_owner'>Owner</label>
<select id='id_owner' name='owner'><option value='0'>Unassign</option>{% for u in active_users %}<option value='{{ u.id }}' {% ifequal u.id ticket.assigned_to.id %}selected{% endifequal %}>{{ u }}</option>{% endfor %}</select>
<label for='id_priority'>Priority</label>
<select id='id_priority' name='priority'>{% for p in priorities %}<option value='{{ p.0 }}'{% ifequal p.0 ticket.priority %} selected='selected'{% endifequal %}>{{ p.1 }}</option>{% endfor %}</select>
</div>
<label for='id_public'>Is this update public?</label> <input type='checkbox' name='public' value='1' checked='checked' />

View File

@ -80,6 +80,7 @@ def view_ticket(request, ticket_id):
RequestContext(request, {
'ticket': ticket,
'active_users': User.objects.filter(is_active=True),
'priorities': Ticket.PRIORITY_CHOICES,
}))
view_ticket = login_required(view_ticket)
@ -91,6 +92,8 @@ def update_ticket(request, ticket_id):
title = request.POST.get('title', '')
public = request.POST.get('public', False)
owner = int(request.POST.get('owner', None))
priority = int(request.POST.get('priority', ticket.priority))
if not owner and ticket.assigned_to:
owner = ticket.assigned_to.id
@ -129,6 +132,11 @@ def update_ticket(request, ticket_id):
c.save()
ticket.title = title
if priority != ticket.priority:
c = TicketChange(followup=f, field='Priority', old_value=ticket.priority, new_value=priority)
c.save()
ticket.priority = priority
if f.new_status == Ticket.RESOLVED_STATUS:
ticket.resolution = comment