mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-11-08 01:04:38 +01:00
Fixes issue #49 - tickets had no 'edit' function.
This commit is contained in:
parent
f2009c687f
commit
353407d251
5
forms.py
5
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'),
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<p>Unless otherwise stated, all fields are required. Please provide as descriptive a title and description as possible.</p>{% endblocktrans %}
|
||||
|
||||
<form method='post' action='./' encrypt='multipart/form-data'>
|
||||
<form method='post' action='./' enctype='multipart/form-data'>
|
||||
<fieldset>
|
||||
<dl>
|
||||
{% for field in form %}
|
||||
|
33
templates/helpdesk/edit_ticket.html
Normal file
33
templates/helpdesk/edit_ticket.html
Normal file
@ -0,0 +1,33 @@
|
||||
{% extends "helpdesk/base.html" %}{% load i18n %}
|
||||
|
||||
{% block helpdesk_title %}{% trans "Edit Ticket" %}{% endblock %}
|
||||
|
||||
{% block helpdesk_body %}
|
||||
{% blocktrans %}<h2>Edit a Ticket</h2>
|
||||
|
||||
<p>Unless otherwise stated, all fields are required. Please provide as descriptive a title and description as possible.</p>
|
||||
|
||||
<p><strong>Note:</strong> Editing a ticket does <em>not</em> 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.</p>{% endblocktrans %}
|
||||
|
||||
<form method='post' action='./'>
|
||||
<fieldset>
|
||||
<dl>
|
||||
{% for field in form %}
|
||||
{% if field.is_hidden %}
|
||||
{{ field }}
|
||||
{% else %}
|
||||
<dt><label for='id_{{ field.name }}'>{{ field.label }}</label>{% if not field.field.required %} <span class='form_optional'>{% trans "(Optional)" %}</span>{% endif %}</dt>
|
||||
<dd>{{ field }}</dd>
|
||||
{% if field.errors %}<dd class='error'>{{ field.errors }}</dd>{% endif %}
|
||||
{% if field.help_text %}<dd class='form_help_text'>{{ field.help_text }}</dd>{% endif %}</label>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</dl>
|
||||
|
||||
<div class='buttons'>
|
||||
<input type='submit' value='{% trans "Save Changes" %}' />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
{% endblock %}
|
@ -43,7 +43,7 @@
|
||||
{% block helpdesk_body %}
|
||||
|
||||
<table width='100%'>
|
||||
<tr class='row_tablehead'><td>{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]</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>{% if ticket.on_hold %}<a href='unhold/'>{% trans "Unhold" %}</a>{% else %}<a href='hold/'>{% trans "Hold" %}</a>{% endif %}</td></tr>
|
||||
<tr class='row_tablehead'><td>{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]</td><td align='right'><a href='{% url helpdesk_edit ticket.id %}'><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>{% if ticket.on_hold %}<a href='unhold/'>{% trans "Unhold" %}</a>{% else %}<a href='hold/'>{% trans "Hold" %}</a>{% endif %}</td></tr>
|
||||
<tr class='row_columnheads'><th colspan='2'>{% blocktrans with ticket.queue as queue %}Queue: {{ queue }}{% endblocktrans %}</th></tr>
|
||||
|
||||
<tr class='row_odd'>
|
||||
|
4
urls.py
4
urls.py
@ -35,6 +35,10 @@ urlpatterns = patterns('helpdesk.views.staff',
|
||||
'view_ticket',
|
||||
name='helpdesk_view'),
|
||||
|
||||
url(r'^tickets/(?P<ticket_id>[0-9]+)/edit/$',
|
||||
'edit_ticket',
|
||||
name='helpdesk_edit'),
|
||||
|
||||
url(r'^tickets/(?P<ticket_id>[0-9]+)/update/$',
|
||||
'update_ticket',
|
||||
name='helpdesk_update'),
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user