mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 01:13:31 +01:00
Fix #1138 by calling update_ticket directly from non-update views
This commit is contained in:
parent
ade4c3115e
commit
b0ef6a5484
@ -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
|
||||
|
@ -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 = ''
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user