Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid saving empty ticket updates. Closes #99.

  • Loading branch information...
commit dc91771b963068ec891d25855678e83f234ad515 1 parent eaba930
@rossp authored
Showing with 19 additions and 1 deletion.
  1. +19 −1 helpdesk/views/staff.py
View
20 helpdesk/views/staff.py
@@ -267,6 +267,19 @@ def update_ticket(request, ticket_id, public=False):
due_date = due_date.replace(due_date_year, due_date_month, due_date_day)
tags = request.POST.get('tags', '')
+ no_changes = all([
+ not request.FILES,
+ not comment,
+ new_status == ticket.status,
+ title == ticket.title,
+ priority == int(ticket.priority),
+ due_date == ticket.due_date,
+ (not owner and not ticket.assigned_to) or (owner and User.objects.get(id=owner) == ticket.assigned_to),
+ (HAS_TAG_SUPPORT and tags == ticket.tags) or not HAS_TAG_SUPPORT,
+ ])
+ if no_changes:
+ return return_to_ticket(request.user, helpdesk_settings, ticket)
+
# We need to allow the 'ticket' and 'queue' contexts to be applied to the
# comment.
from django.template import loader, Context
@@ -469,7 +482,12 @@ def update_ticket(request, ticket_id, public=False):
ticket.save()
- if request.user.is_staff or helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
+ return return_to_ticket(request.user, helpdesk_settings, ticket)
+
+def return_to_ticket(user, helpdesk_settings, ticket):
+ ''' Helpder function for update_ticket '''
+
+ if user.is_staff or helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
return HttpResponseRedirect(ticket.get_absolute_url())
else:
return HttpResponseRedirect(ticket.ticket_url)
Please sign in to comment.
Something went wrong with that request. Please try again.