diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index 0a3f2c85..d26a9ed3 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -194,7 +194,7 @@ def update_ticket( user, ticket, title=None, - comment=None, + comment="", files=None, public=False, owner=-1, @@ -207,6 +207,8 @@ def update_ticket( # We need to allow the 'ticket' and 'queue' contexts to be applied to the # comment. context = safe_template_context(ticket) + if title is None: + title = ticket.title if priority == -1: priority = ticket.priority if new_status is None: @@ -309,6 +311,8 @@ def update_ticket( ticket.due_date = due_date for checklist in ticket.checklists.all(): + if checklist.id not in new_checklists: + continue new_completed_tasks = new_checklists[checklist.id] for task in checklist.tasks.all(): changed = None diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index f2eca65f..c2d15b6d 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -210,21 +210,16 @@ def view_ticket(request): return HttpResponseRedirect(redirect_url) if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS: - from helpdesk.views.staff import update_ticket_view + from helpdesk.update_ticket import update_ticket + update_ticket( + request.user, + ticket, + public = True, + comment = _('Submitter accepted resolution and closed ticket'), + new_status = Ticket.CLOSED_STATUS, + ) + return HttpResponseRedirect(ticket.ticket_url) - # Trick the update_ticket() view into thinking it's being called with - # a valid POST. - request.POST = { - 'new_status': Ticket.CLOSED_STATUS, - 'public': 1, - 'title': ticket.title, - 'comment': _('Submitter accepted resolution and closed ticket'), - } - if ticket.assigned_to: - request.POST['owner'] = ticket.assigned_to.id - request.GET = {} - - return update_ticket_view(request, ticket_id, public=True) # redirect user back to this ticket if possible. redirect_url = '' diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index f1ca91e6..44ee9b29 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -347,17 +347,12 @@ def view_ticket(request, ticket_id): ticket_perm_check(request, ticket) if 'take' in request.GET: - # Allow the user to assign the ticket to themselves whilst viewing it. - - # Trick the update_ticket() view into thinking it's being called with - # a valid POST. - request.POST = { - 'owner': request.user.id, - 'public': 1, - 'title': ticket.title, - 'comment': '' - } - return update_ticket_view(request, ticket_id) + update_ticket( + request.user, + ticket, + owner=request.user.id + ) + return return_to_ticket(request.user, helpdesk_settings, ticket) if 'subscribe' in request.GET: # Allow the user to subscribe him/herself to the ticket whilst viewing @@ -376,17 +371,13 @@ def view_ticket(request, ticket_id): else: owner = ticket.assigned_to.id - # Trick the update_ticket() view into thinking it's being called with - # a valid POST. - request.POST = { - 'new_status': Ticket.CLOSED_STATUS, - 'public': 1, - 'owner': owner, - 'title': ticket.title, - 'comment': _('Accepted resolution and closed ticket'), - } - - return update_ticket_view(request, ticket_id) + update_ticket( + request.user, + ticket, + owner=owner, + comment= _('Accepted resolution and closed ticket'), + ) + return return_to_ticket(request.user, helpdesk_settings, ticket) if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS: users = User.objects.filter(