* Add ability to delete tickets completely

* Add model for file attachments, although currently commented out.
This commit is contained in:
Ross Poulton 2008-01-15 04:00:19 +00:00
parent 038ea15877
commit 14b2c59093
5 changed files with 42 additions and 10 deletions

View File

@ -236,9 +236,18 @@ class TicketChange(models.Model):
str += 'changed from "%s" to "%s"' % (old_value, new_value)
return str
#class Attachment(models.Model):
#followup = models.ForeignKey(FollowUp, edit_inline=models.TABULAR)
#file = models.FileField()
"""class Attachment(models.Model):
followup = models.ForeignKey(FollowUp, edit_inline=models.TABULAR)
file = models.FileField()
filename = models.CharField(maxlength=100)
mime_type = models.CharField(maxlength=30)
size = models.IntegerField(help_text='Size of this file in bytes')
def __unicode__(self):
return u'%s' % self.filename
class Meta:
ordering = ['filename',] """
class PreSetReply(models.Model):
""" We can allow the admin to define a number of pre-set replies, used to

View File

@ -0,0 +1,11 @@
{% extends "helpdesk/base.html" %}
{% block helpdesk_title %}Delete Ticket{% endblock %}
{% block helpdesk_body %}
<h2>Delete Ticket</h2>
<p>Are you sure you want to delete this ticket (<em>{{ ticket.title }}</em>)? All traces of the ticket, including followups, attachments, and updates will be irreversably removed.</p>
<p><a href='../'>No, Don't Delete It</a></p>
<form method='post' action='./'><input type='submit' value='Yes - Delete It' /></form>
{% endblock %}

View File

@ -25,7 +25,7 @@
{% block helpdesk_body %}
<table width='100%'>
<tr class='row_tablehead'><td>{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status_display }}]</td><td align='right'><a href='#edit'><img src='{{ MEDIA_URL }}/helpdesk/buttons/edit.png' alt='Edit' title='Edit' width='60' height='15' /></a><a href='?delete'><img src='{{ MEDIA_URL }}/helpdesk/buttons/delete.png' alt='Delete' title='Delete' width='60' height='15' /></a></td></tr>
<tr class='row_tablehead'><td>{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status_display }}]</td><td align='right'><a href='#edit'><img src='{{ MEDIA_URL }}/helpdesk/buttons/edit.png' alt='Edit' title='Edit' width='60' height='15' /></a><a href='{% url helpdesk_delete ticket.id %}'><img src='{{ MEDIA_URL }}/helpdesk/buttons/delete.png' alt='Delete' title='Delete' width='60' height='15' /></a></td></tr>
<tr class='row_columnheads'><th colspan='2'>Queue: {{ ticket.queue }}</th></tr>
<tr class='row_odd'>

View File

@ -49,6 +49,11 @@ urlpatterns = patterns('helpdesk.views',
url(r'^tickets/(?P<ticket_id>[0-9]+)/update/$',
'update_ticket',
name='helpdesk_update'),
url(r'^tickets/(?P<ticket_id>[0-9]+)/delete/$',
'delete_ticket',
name='helpdesk_delete'),
url(r'^raw/(?P<type>\w+)/$',
'raw_details',

View File

@ -63,18 +63,25 @@ def dashboard(request):
}))
dashboard = login_required(dashboard)
def delete_ticket(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id)
if request.method == 'GET':
return render_to_response('helpdesk/delete_ticket.html',
RequestContext(request, {
'ticket': ticket,
}))
else:
ticket.delete()
return HttpResponseRedirect(reverse('helpdesk_home'))
delete_ticket = login_required(delete_ticket)
def view_ticket(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id)
if request.GET.has_key('take'):
ticket.assigned_to = request.user
ticket.save()
if request.GET.has_key('delete'):
if request.method == 'GET':
else:
ticket.delete()
return HttpResponseRedirect(reverse('helpdesk_dashboard'))
if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
if not ticket.assigned_to:
owner = 0