Merge pull request #944 from alligatorbait/merged_to

Fix a bug in EditTicketForm preventing edits
This commit is contained in:
Garret Wassermann 2021-02-09 15:14:20 -05:00 committed by GitHub
commit 7559e2aa74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -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)

View File

@ -26,6 +26,7 @@
<strong>{% trans "Note" %}:</strong>
{% blocktrans %}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.{% endblocktrans %}
</p>
{% if errors %}{% for error in errors %}{% trans "Error: " %}{{ error }}{% endfor %}{% endif %}
<form method='post'>
{% csrf_token %}
<fieldset>

View File

@ -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)