Merge pull request #662 from auto-mat/email-fixes

Email fixes relating to refactor
This commit is contained in:
Garret Wassermann 2018-11-01 14:44:34 -04:00 committed by GitHub
commit 7cd6c37ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View File

@ -534,7 +534,7 @@ class Ticket(models.Model):
recipients.add(recipient)
send('submitter', self.submitter_email)
send('new_ticket_cc', self.queue.new_ticket_cc)
if self.assigned_to and self.assigned_to.usersettings_helpdesk.email_on_ticket_assign:
if self.assigned_to:
send('assigned_to', self.assigned_to.email)
send('ticket_cc', self.queue.updated_ticket_cc)
for cc in self.ticketcc_set.all():

View File

@ -604,8 +604,9 @@ def update_ticket(request, ticket_id, public=False):
roles = {
'submitter': (template + 'submitter', context),
'ticket_cc': (template + 'cc', context),
'assigned_to': (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:
@ -617,12 +618,13 @@ def update_ticket(request, ticket_id, public=False):
else:
template_staff = 'updated_owner'
messages_sent_to.update(ticket.send(
{'assigned_to': (template_staff, context)},
dont_send_to=messages_sent_to,
fail_silently=True,
files=files,
))
if ticket.assigned_to and (ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change or (reassigned and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_assigned)):
messages_sent_to.update(ticket.send(
{'assigned_to': (template_staff, context)},
dont_send_to=messages_sent_to,
fail_silently=True,
files=files,
))
if reassigned:
template_cc = 'assigned_cc'
@ -730,10 +732,15 @@ def mass_update(request):
except AttributeError:
pass
roles = {
'submitter': ('closed_submitter', context),
'ticket_cc': ('closed_cc', context),
}
if ticket.assigned_to and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change:
roles['assigned_to'] = ('closed_owner', context),
messages_sent_to.update(t.send(
{'submitter': ('closed_submitter', context),
'ticket_cc': ('closed_cc', context),
'assigned_to': ('closded_owner', context)},
roles,
dont_send_to=messages_sent_to,
fail_silently=True,
))