Fix an issue where notifications might not always be triggered

In the case where a notification template were assigned to "failed"
events but not "success" or "any" events.
This commit is contained in:
Matthew Jones 2017-03-06 15:18:38 -05:00
parent a2320c5b5e
commit 90a26de180

View File

@ -218,7 +218,11 @@ def _send_notification_templates(instance, status_str):
raise ValueError(_("status_str must be either succeeded or failed"))
notification_templates = instance.get_notification_templates()
if notification_templates:
all_notification_templates = set(notification_templates.get('success', []) + notification_templates.get('any', []))
if status_str == 'succeeded':
notification_template_type = 'success'
else:
notification_template_type = 'error'
all_notification_templates = set(notification_templates.get(notification_template_type, []) + notification_templates.get('any', []))
if len(all_notification_templates):
try:
(notification_subject, notification_body) = getattr(instance, 'build_notification_%s_message' % status_str)()