new option 'HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP' which allows superusers

to delete individual followups (so you don't have to go to the admin).
(by @kotowicz in a2a5b10b2d)
This commit is contained in:
Ross Poulton 2012-08-07 23:32:45 +10:00
parent 5c2a1df976
commit 2f1b74316f
4 changed files with 31 additions and 5 deletions

View File

@ -91,6 +91,9 @@ HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE = getattr(settings, 'HELPDESK_ALLOW_NON_S
# show edit buttons in ticket follow ups.
HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP = getattr(settings, 'HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP', True)
# show delete buttons in ticket follow ups if user is 'superuser'
HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP = getattr(settings, 'HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP', False)
# show ticket edit button on top of ticket description.
HELPDESK_SHOW_EDIT_BUTTON_TICKET_TOP = getattr(settings, 'HELPDESK_SHOW_EDIT_BUTTON_TICKET_TOP', True)

View File

@ -74,6 +74,9 @@ function googleTranslateElementInit() {
<a href="{% url helpdesk_followup_edit ticket.id followup.id %}" class='followup-edit'><img width="60" height="15" title="Edit" alt="Edit" src="{{ STATIC_URL }}helpdesk/buttons/edit.png"></a>
{% endif %}
{% endif %}
{% if user.is_superuser and helpdesk_settings.HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP %}
<a href="{% url helpdesk_followup_delete ticket.id followup.id %}" class='followup-edit'><img width="60" height="15" title="Delete" alt="Delete" src="{{ STATIC_URL }}helpdesk/buttons/delete.png"></a>
{% endif %}
</div>
{% else %}
<div class='followup'>
@ -84,6 +87,9 @@ function googleTranslateElementInit() {
<a href="{% url helpdesk_followup_edit ticket.id followup.id %}" class='followup-edit'><img width="60" height="15" title="Edit" alt="Edit" src="{{ STATIC_URL }}helpdesk/buttons/edit.png"></a>
{% endif %}
{% endif %}
{% if user.is_superuser and helpdesk_settings.HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP %}
<a href="{% url helpdesk_followup_delete ticket.id followup.id %}" class='followup-edit'><img width="60" height="15" title="Delete" alt="Delete" src="{{ STATIC_URL }}helpdesk/buttons/delete.png"></a>
{% endif %}
</div>
{% endif %}
<span class='followup-desc'>{% if followup.comment %}{{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}{% endif %}</span>

View File

@ -39,6 +39,10 @@ urlpatterns = patterns('helpdesk.views.staff',
'followup_edit',
name='helpdesk_followup_edit'),
url(r'^tickets/(?P<ticket_id>[0-9]+)/followup_delete/(?P<followup_id>[0-9]+)/$',
'followup_delete',
name='helpdesk_followup_delete'),
url(r'^tickets/(?P<ticket_id>[0-9]+)/edit/$',
'edit_ticket',
name='helpdesk_edit'),

View File

@ -143,7 +143,7 @@ def delete_ticket(request, ticket_id):
return HttpResponseRedirect(reverse('helpdesk_home'))
delete_ticket = staff_member_required(delete_ticket)
def followup_edit(request, ticket_id, followup_id, ):
def followup_edit(request, ticket_id, followup_id):
"Edit followup options with an ability to change the ticket."
followup = get_object_or_404(FollowUp, id=followup_id)
ticket = get_object_or_404(Ticket, id=ticket_id)
@ -155,7 +155,7 @@ def followup_edit(request, ticket_id, followup_id, ):
'public': followup.public,
'new_status': followup.new_status,
})
return render_to_response('helpdesk/followup_edit.html',
RequestContext(request, {
'followup': followup,
@ -178,14 +178,27 @@ def followup_edit(request, ticket_id, followup_id, ):
new_followup.user = followup.user
new_followup.save()
# get list of old attachments & link them to new_followup
attachments = Attachment.objects.filter(followup = followup)
attachments = Attachment.objects.filter(followup = followup)
for attachment in attachments:
attachment.followup = new_followup
attachment.save()
# delete old followup
followup.delete()
followup.delete()
return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
def followup_delete(request, ticket_id, followup_id):
''' followup delete for superuser'''
ticket = get_object_or_404(Ticket, id=ticket_id)
if not request.user.is_superuser:
return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
followup = get_object_or_404(FollowUp, id=followup_id)
followup.delete()
return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
def view_ticket(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id)