Skip to content

Commit

Permalink
Merge pull request #893 from Benbb96/fix-739
Browse files Browse the repository at this point in the history
Redirect to dashboard after deleting a ticket from there, to fix #739
  • Loading branch information
gwasser committed Oct 23, 2020
2 parents ab5e07e + dc503b0 commit fe785bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion helpdesk/templates/helpdesk/delete_ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ <h2>{% trans "Delete Ticket" %}</h2>
<p><a href='../'><button class="btn btn-primary btn-lg">{% trans "No, Don't Delete It" %}</button></a></p>

<form method='post' action='./'>
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}">
<button class="btn btn-danger" type='submit'>{% trans "Yes I Understand - Delete It Anyway" %}</button>
{% csrf_token %}</form>
</form>
{% endblock %}
4 changes: 2 additions & 2 deletions helpdesk/templates/helpdesk/include/unassigned.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></td>
<td class="text-center">
<a href='{{ ticket.get_absolute_url }}?take'><button class='btn btn-primary btn-sm'><i class="fas fa-hand-paper"></i>&nbsp;{% trans "Take" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}?next=dashboard'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>
</td>
</tr>
{% empty %}
Expand Down Expand Up @@ -66,7 +66,7 @@
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></td>
<td class="text-center">
<a href='{{ ticket.get_absolute_url }}?take'><button class='btn btn-primary btn-sm'><i class="fas fa-hand-paper"></i>&nbsp;{% trans "Take" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}?next=dashboard'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>
</td>
</tr>
{% empty %}
Expand Down
6 changes: 5 additions & 1 deletion helpdesk/views/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,14 @@ def delete_ticket(request, ticket_id):
if request.method == 'GET':
return render(request, 'helpdesk/delete_ticket.html', {
'ticket': ticket,
'next': request.GET.get('next', 'home')
})
else:
ticket.delete()
return HttpResponseRedirect(reverse('helpdesk:home'))
redirect_to = 'helpdesk:home'
if request.POST.get('next') == 'dashboard':
redirect_to = 'helpdesk:dashboard'
return HttpResponseRedirect(reverse(redirect_to))


delete_ticket = staff_member_required(delete_ticket)
Expand Down

0 comments on commit fe785bd

Please sign in to comment.