From ae9109bad6f33ff9d1272ec57796a18f37e2ac47 Mon Sep 17 00:00:00 2001 From: Tom Weber <60234929+alligatorbait@users.noreply.github.com> Date: Tue, 9 Feb 2021 13:08:27 -0700 Subject: [PATCH] Bug Fix EditTicketForm unable to edit and add error display --- helpdesk/forms.py | 10 ++++------ helpdesk/templates/helpdesk/edit_ticket.html | 1 + helpdesk/views/staff.py | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index cc731c2a..50fa61e9 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -83,12 +83,6 @@ 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 @@ -100,6 +94,10 @@ class EditTicketForm(CustomFieldMixin, forms.ModelForm): """ super(EditTicketForm, self).__init__(*args, **kwargs) + # Disable and add help_text to the merged_to field on this form + self.fields['merged_to'].disabled = True + self.fields['merged_to'].help_text = _('This ticket is merged into the selected ticket.') + for field in CustomField.objects.all(): try: current_value = TicketCustomFieldValue.objects.get(ticket=self.instance, field=field) diff --git a/helpdesk/templates/helpdesk/edit_ticket.html b/helpdesk/templates/helpdesk/edit_ticket.html index fbef1bfb..69df01de 100644 --- a/helpdesk/templates/helpdesk/edit_ticket.html +++ b/helpdesk/templates/helpdesk/edit_ticket.html @@ -26,6 +26,7 @@ {% 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 %}

+ {% if errors %}{% for error in errors %}{% trans "Error: " %}{{ error }}{% endfor %}{% endif %}
{% csrf_token %}
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 90d60054..69e403c2 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -1218,7 +1218,7 @@ def edit_ticket(request, ticket_id): ticket = form.save() return redirect(ticket) - return render(request, 'helpdesk/edit_ticket.html', {'form': form, 'ticket': ticket}) + return render(request, 'helpdesk/edit_ticket.html', {'form': form, 'ticket': ticket, 'errors': form.errors}) edit_ticket = staff_member_required(edit_ticket)