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

This commit is contained in:
Andreas Kotowicz 2012-01-12 12:44:09 +01:00
parent 11283741a2
commit a2a5b10b2d
4 changed files with 28 additions and 2 deletions

View File

@ -85,6 +85,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

@ -41,6 +41,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

@ -139,7 +139,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)
@ -179,8 +179,21 @@ def followup_edit(request, ticket_id, followup_id, ):
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)