mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 16:03:19 +01:00
Add update_messages_sent_to_by_public_and_status
helper function
Handles updating ticket and sending ticket reply
This commit is contained in:
parent
fe619b5ff2
commit
f678c63496
@ -601,6 +601,47 @@ def get_time_spent_from_request(request: WSGIRequest) -> typing.Optional[timedel
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def update_messages_sent_to_by_public_and_status(
|
||||||
|
public: bool,
|
||||||
|
ticket: Ticket,
|
||||||
|
follow_up: FollowUp,
|
||||||
|
context: str,
|
||||||
|
messages_sent_to: list[str],
|
||||||
|
files: list[str, str]
|
||||||
|
) -> Ticket:
|
||||||
|
"""Sets the status of the ticket"""
|
||||||
|
if public and (
|
||||||
|
follow_up.comment or (
|
||||||
|
follow_up.new_status in (
|
||||||
|
Ticket.RESOLVED_STATUS,
|
||||||
|
Ticket.CLOSED_STATUS
|
||||||
|
)
|
||||||
|
)
|
||||||
|
):
|
||||||
|
if follow_up.new_status == Ticket.RESOLVED_STATUS:
|
||||||
|
template = 'resolved_'
|
||||||
|
elif follow_up.new_status == Ticket.CLOSED_STATUS:
|
||||||
|
template = 'closed_'
|
||||||
|
else:
|
||||||
|
template = 'updated_'
|
||||||
|
|
||||||
|
roles = {
|
||||||
|
'submitter': (template + 'submitter', context),
|
||||||
|
'ticket_cc': (template + 'cc', context),
|
||||||
|
}
|
||||||
|
if ticket.assigned_to and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change:
|
||||||
|
roles['assigned_to'] = (template + 'cc', context)
|
||||||
|
messages_sent_to.update(
|
||||||
|
ticket.send(
|
||||||
|
roles,
|
||||||
|
dont_send_to=messages_sent_to,
|
||||||
|
fail_silently=True,
|
||||||
|
files=files
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return ticket
|
||||||
|
|
||||||
|
|
||||||
def update_ticket(request, ticket_id, public=False):
|
def update_ticket(request, ticket_id, public=False):
|
||||||
|
|
||||||
ticket = get_ticket_from_request_with_authorisation(request, ticket_id, public)
|
ticket = get_ticket_from_request_with_authorisation(request, ticket_id, public)
|
||||||
@ -748,24 +789,14 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
messages_sent_to.add(request.user.email)
|
messages_sent_to.add(request.user.email)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
if public and (f.comment or (
|
ticket = update_messages_sent_to_by_public_and_status(
|
||||||
f.new_status in (Ticket.RESOLVED_STATUS,
|
public,
|
||||||
Ticket.CLOSED_STATUS))):
|
ticket,
|
||||||
if f.new_status == Ticket.RESOLVED_STATUS:
|
f,
|
||||||
template = 'resolved_'
|
context,
|
||||||
elif f.new_status == Ticket.CLOSED_STATUS:
|
messages_sent_to,
|
||||||
template = 'closed_'
|
files
|
||||||
else:
|
)
|
||||||
template = 'updated_'
|
|
||||||
|
|
||||||
roles = {
|
|
||||||
'submitter': (template + 'submitter', context),
|
|
||||||
'ticket_cc': (template + 'cc', context),
|
|
||||||
}
|
|
||||||
if ticket.assigned_to and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change:
|
|
||||||
roles['assigned_to'] = (template + 'cc', context)
|
|
||||||
messages_sent_to.update(ticket.send(
|
|
||||||
roles, dont_send_to=messages_sent_to, fail_silently=True, files=files,))
|
|
||||||
|
|
||||||
if reassigned:
|
if reassigned:
|
||||||
template_staff = 'assigned_owner'
|
template_staff = 'assigned_owner'
|
||||||
|
Loading…
Reference in New Issue
Block a user