mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +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,
|
user,
|
||||||
ticket,
|
ticket,
|
||||||
title=None,
|
title=None,
|
||||||
comment=None,
|
comment="",
|
||||||
files=None,
|
files=None,
|
||||||
public=False,
|
public=False,
|
||||||
owner=-1,
|
owner=-1,
|
||||||
@ -207,6 +207,8 @@ def update_ticket(
|
|||||||
# We need to allow the 'ticket' and 'queue' contexts to be applied to the
|
# We need to allow the 'ticket' and 'queue' contexts to be applied to the
|
||||||
# comment.
|
# comment.
|
||||||
context = safe_template_context(ticket)
|
context = safe_template_context(ticket)
|
||||||
|
if title is None:
|
||||||
|
title = ticket.title
|
||||||
if priority == -1:
|
if priority == -1:
|
||||||
priority = ticket.priority
|
priority = ticket.priority
|
||||||
if new_status is None:
|
if new_status is None:
|
||||||
@ -309,6 +311,8 @@ def update_ticket(
|
|||||||
ticket.due_date = due_date
|
ticket.due_date = due_date
|
||||||
|
|
||||||
for checklist in ticket.checklists.all():
|
for checklist in ticket.checklists.all():
|
||||||
|
if checklist.id not in new_checklists:
|
||||||
|
continue
|
||||||
new_completed_tasks = new_checklists[checklist.id]
|
new_completed_tasks = new_checklists[checklist.id]
|
||||||
for task in checklist.tasks.all():
|
for task in checklist.tasks.all():
|
||||||
changed = None
|
changed = None
|
||||||
|
@ -210,21 +210,16 @@ def view_ticket(request):
|
|||||||
return HttpResponseRedirect(redirect_url)
|
return HttpResponseRedirect(redirect_url)
|
||||||
|
|
||||||
if 'close' in request.GET and ticket.status == Ticket.RESOLVED_STATUS:
|
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 user back to this ticket if possible.
|
||||||
redirect_url = ''
|
redirect_url = ''
|
||||||
|
@ -347,17 +347,12 @@ def view_ticket(request, ticket_id):
|
|||||||
ticket_perm_check(request, ticket)
|
ticket_perm_check(request, ticket)
|
||||||
|
|
||||||
if 'take' in request.GET:
|
if 'take' in request.GET:
|
||||||
# Allow the user to assign the ticket to themselves whilst viewing it.
|
update_ticket(
|
||||||
|
request.user,
|
||||||
# Trick the update_ticket() view into thinking it's being called with
|
ticket,
|
||||||
# a valid POST.
|
owner=request.user.id
|
||||||
request.POST = {
|
)
|
||||||
'owner': request.user.id,
|
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
||||||
'public': 1,
|
|
||||||
'title': ticket.title,
|
|
||||||
'comment': ''
|
|
||||||
}
|
|
||||||
return update_ticket_view(request, ticket_id)
|
|
||||||
|
|
||||||
if 'subscribe' in request.GET:
|
if 'subscribe' in request.GET:
|
||||||
# Allow the user to subscribe him/herself to the ticket whilst viewing
|
# Allow the user to subscribe him/herself to the ticket whilst viewing
|
||||||
@ -376,17 +371,13 @@ def view_ticket(request, ticket_id):
|
|||||||
else:
|
else:
|
||||||
owner = ticket.assigned_to.id
|
owner = ticket.assigned_to.id
|
||||||
|
|
||||||
# Trick the update_ticket() view into thinking it's being called with
|
update_ticket(
|
||||||
# a valid POST.
|
request.user,
|
||||||
request.POST = {
|
ticket,
|
||||||
'new_status': Ticket.CLOSED_STATUS,
|
owner=owner,
|
||||||
'public': 1,
|
comment= _('Accepted resolution and closed ticket'),
|
||||||
'owner': owner,
|
)
|
||||||
'title': ticket.title,
|
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
||||||
'comment': _('Accepted resolution and closed ticket'),
|
|
||||||
}
|
|
||||||
|
|
||||||
return update_ticket_view(request, ticket_id)
|
|
||||||
|
|
||||||
if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS:
|
if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS:
|
||||||
users = User.objects.filter(
|
users = User.objects.filter(
|
||||||
|
Loading…
Reference in New Issue
Block a user