This commit is contained in:
bbe 2020-10-23 14:51:53 +02:00
parent ab5e07e295
commit dc503b0437
3 changed files with 10 additions and 4 deletions

View File

@ -20,6 +20,8 @@
<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 %}

View File

@ -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 %}
@ -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 %}

View File

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