mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-06 17:56:58 +02:00
Add get_template_staff_and_template_cc
function
Furhter reduxes complexity by combining creation of templates
This commit is contained in:
parent
256af24daa
commit
595dae1cf7
@ -657,6 +657,29 @@ def add_staff_subscription(
|
|||||||
subscribe_staff_member_to_ticket(ticket, request.user)
|
subscribe_staff_member_to_ticket(ticket, request.user)
|
||||||
|
|
||||||
|
|
||||||
|
def get_template_staff_and_template_cc(
|
||||||
|
reassigned, follow_up: FollowUp
|
||||||
|
) -> tuple[str, str]:
|
||||||
|
if reassigned:
|
||||||
|
template_staff = 'assigned_owner'
|
||||||
|
elif follow_up.new_status == Ticket.RESOLVED_STATUS:
|
||||||
|
template_staff = 'resolved_owner'
|
||||||
|
elif follow_up.new_status == Ticket.CLOSED_STATUS:
|
||||||
|
template_staff = 'closed_owner'
|
||||||
|
else:
|
||||||
|
template_staff = 'updated_owner'
|
||||||
|
if reassigned:
|
||||||
|
template_cc = 'assigned_cc'
|
||||||
|
elif follow_up.new_status == Ticket.RESOLVED_STATUS:
|
||||||
|
template_cc = 'resolved_cc'
|
||||||
|
elif follow_up.new_status == Ticket.CLOSED_STATUS:
|
||||||
|
template_cc = 'closed_cc'
|
||||||
|
else:
|
||||||
|
template_cc = 'updated_cc'
|
||||||
|
|
||||||
|
return template_staff, template_cc
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@ -813,15 +836,7 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
files
|
files
|
||||||
)
|
)
|
||||||
|
|
||||||
if reassigned:
|
template_staff, template_cc = get_template_staff_and_template_cc(reassigned, f)
|
||||||
template_staff = 'assigned_owner'
|
|
||||||
elif f.new_status == Ticket.RESOLVED_STATUS:
|
|
||||||
template_staff = 'resolved_owner'
|
|
||||||
elif f.new_status == Ticket.CLOSED_STATUS:
|
|
||||||
template_staff = 'closed_owner'
|
|
||||||
else:
|
|
||||||
template_staff = 'updated_owner'
|
|
||||||
|
|
||||||
if ticket.assigned_to and (
|
if ticket.assigned_to and (
|
||||||
ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change
|
ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change
|
||||||
or (reassigned and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_assign)
|
or (reassigned and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_assign)
|
||||||
@ -833,15 +848,6 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
files=files,
|
files=files,
|
||||||
))
|
))
|
||||||
|
|
||||||
if reassigned:
|
|
||||||
template_cc = 'assigned_cc'
|
|
||||||
elif f.new_status == Ticket.RESOLVED_STATUS:
|
|
||||||
template_cc = 'resolved_cc'
|
|
||||||
elif f.new_status == Ticket.CLOSED_STATUS:
|
|
||||||
template_cc = 'closed_cc'
|
|
||||||
else:
|
|
||||||
template_cc = 'updated_cc'
|
|
||||||
|
|
||||||
messages_sent_to.update(ticket.send(
|
messages_sent_to.update(ticket.send(
|
||||||
{'ticket_cc': (template_cc, context)},
|
{'ticket_cc': (template_cc, context)},
|
||||||
dont_send_to=messages_sent_to,
|
dont_send_to=messages_sent_to,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user