Skip to content

Commit

Permalink
Merge pull request #944 from alligatorbait/merged_to
Browse files Browse the repository at this point in the history
Fix a bug in EditTicketForm preventing edits
  • Loading branch information
gwasser committed Feb 9, 2021
2 parents 0d0cbac + ae9109b commit 7559e2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions helpdesk/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ def customfield_to_field(self, field, instanceargs):


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
Expand All @@ -100,6 +94,10 @@ def __init__(self, *args, **kwargs):
"""
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)
Expand Down
1 change: 1 addition & 0 deletions helpdesk/templates/helpdesk/edit_ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion helpdesk/views/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7559e2a

Please sign in to comment.