diff --git a/forms.py b/forms.py index 28019056..a373eb2a 100644 --- a/forms.py +++ b/forms.py @@ -17,6 +17,11 @@ from django.utils.translation import ugettext as _ from helpdesk.lib import send_templated_mail from helpdesk.models import Ticket, Queue, FollowUp, Attachment, IgnoreEmail +class EditTicketForm(forms.ModelForm): + class Meta: + model = Ticket + exclude = ('created', 'modified', 'status', 'on_hold', 'resolution', 'last_escalation', 'assigned_to') + class TicketForm(forms.Form): queue = forms.ChoiceField( label=_('Queue'), diff --git a/templates/helpdesk/create_ticket.html b/templates/helpdesk/create_ticket.html index 911a6c09..669d7ab9 100644 --- a/templates/helpdesk/create_ticket.html +++ b/templates/helpdesk/create_ticket.html @@ -7,7 +7,7 @@

Unless otherwise stated, all fields are required. Please provide as descriptive a title and description as possible.

{% endblocktrans %} -
+
{% for field in form %} diff --git a/templates/helpdesk/edit_ticket.html b/templates/helpdesk/edit_ticket.html new file mode 100644 index 00000000..c57abce7 --- /dev/null +++ b/templates/helpdesk/edit_ticket.html @@ -0,0 +1,33 @@ +{% extends "helpdesk/base.html" %}{% load i18n %} + +{% block helpdesk_title %}{% trans "Edit Ticket" %}{% endblock %} + +{% block helpdesk_body %} +{% blocktrans %}

Edit a Ticket

+ +

Unless otherwise stated, all fields are required. Please provide as descriptive a title and description as possible.

+ +

Note: Editing a ticket does not send an e-mail to the ticket owner or submitter. No new details should be entered, this form should only be used to fix incorrect details or clean up the submission.

{% endblocktrans %} + + +
+
+ {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% else %} +
{% if not field.field.required %} {% trans "(Optional)" %}{% endif %}
+
{{ field }}
+ {% if field.errors %}
{{ field.errors }}
{% endif %} + {% if field.help_text %}
{{ field.help_text }}
{% endif %} + {% endif %} + {% endfor %} +
+ +
+ +
+
+ + +{% endblock %} diff --git a/templates/helpdesk/ticket.html b/templates/helpdesk/ticket.html index aab442ed..778d654f 100644 --- a/templates/helpdesk/ticket.html +++ b/templates/helpdesk/ticket.html @@ -43,7 +43,7 @@ {% block helpdesk_body %} - + diff --git a/urls.py b/urls.py index 5a4de234..162c4086 100644 --- a/urls.py +++ b/urls.py @@ -35,6 +35,10 @@ urlpatterns = patterns('helpdesk.views.staff', 'view_ticket', name='helpdesk_view'), + url(r'^tickets/(?P[0-9]+)/edit/$', + 'edit_ticket', + name='helpdesk_edit'), + url(r'^tickets/(?P[0-9]+)/update/$', 'update_ticket', name='helpdesk_update'), diff --git a/views/staff.py b/views/staff.py index bbde4042..e5e1c64d 100644 --- a/views/staff.py +++ b/views/staff.py @@ -21,7 +21,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import loader, Context, RequestContext from django.utils.translation import ugettext as _ -from helpdesk.forms import TicketForm, UserSettingsForm, EmailIgnoreForm +from helpdesk.forms import TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm from helpdesk.lib import send_templated_mail, line_chart, bar_chart, query_to_dict, apply_query, safe_template_context from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch, IgnoreEmail @@ -522,6 +522,21 @@ def ticket_list(request): ticket_list = staff_member_required(ticket_list) +def edit_ticket(request, ticket_id): + ticket = get_object_or_404(Ticket, id=ticket_id) + if request.method == 'POST': + form = EditTicketForm(request.POST, instance=ticket) + if form.is_valid(): + ticket = form.save() + return HttpResponseRedirect(ticket.get_absolute_url()) + else: + form = EditTicketForm(instance=ticket) + + return render_to_response('helpdesk/edit_ticket.html', + RequestContext(request, { + 'form': form, + })) + def create_ticket(request): if request.method == 'POST': form = TicketForm(request.POST, request.FILES)
{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]EditDelete{% if ticket.on_hold %}{% trans "Unhold" %}{% else %}{% trans "Hold" %}{% endif %}
{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]EditDelete{% if ticket.on_hold %}{% trans "Unhold" %}{% else %}{% trans "Hold" %}{% endif %}
{% blocktrans with ticket.queue as queue %}Queue: {{ queue }}{% endblocktrans %}