diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 92594fca..cc731c2a 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -83,6 +83,12 @@ class CustomFieldMixin(object): class EditTicketForm(CustomFieldMixin, forms.ModelForm): + merged_to = forms.ModelChoiceField( + label=_('Merged to'), + help_text=_('This ticket is merged into the selected ticket.'), + queryset=Ticket.objects.all(), + disabled=True + ) class Meta: model = Ticket diff --git a/helpdesk/templates/helpdesk/edit_ticket.html b/helpdesk/templates/helpdesk/edit_ticket.html index 057e0097..fbef1bfb 100644 --- a/helpdesk/templates/helpdesk/edit_ticket.html +++ b/helpdesk/templates/helpdesk/edit_ticket.html @@ -1,58 +1,52 @@ -{% extends "helpdesk/base.html" %}{% load i18n bootstrap4form %} +{% extends "helpdesk/base.html" %} + +{% load i18n bootstrap4form %} {% block helpdesk_title %}{% trans "Edit Ticket" %}{% endblock %} {% block helpdesk_breadcrumb %} - - - + + + {% endblock %} {% block helpdesk_body %} -
-
- -

{% trans "Edit a Ticket" %}

- -

{% trans "Unless otherwise stated, all fields are required." %} {% trans "Please provide as descriptive a title and description as possible." %}

- -

{% trans "Note" %}: {% blocktrans %}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 %}

- -
-
- {{ form|bootstrap4form }} - {% comment %} - {% 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 %} - - {% endcomment %} -
- - +
+
+

{% trans "Edit a Ticket" %}

+

+ {% trans "Unless otherwise stated, all fields are required." %} + {% trans "Please provide as descriptive a title and description as possible." %} +

+

+ {% trans "Note" %}: + {% blocktrans %}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 %} +

+ + {% csrf_token %} +
+ {{ form|bootstrap4form }} + +
+ +
+
-
- -{% csrf_token %} -
-
-
- - - +{% endblock %} + +{% block helpdesk_js %} + {% endblock %} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 95b5b031..90d60054 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -1213,13 +1213,10 @@ def edit_ticket(request, ticket_id): ticket = get_object_or_404(Ticket, id=ticket_id) ticket_perm_check(request, ticket) - 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) + form = EditTicketForm(request.POST or None, instance=ticket) + if form.is_valid(): + ticket = form.save() + return redirect(ticket) return render(request, 'helpdesk/edit_ticket.html', {'form': form, 'ticket': ticket})