From 462d43060e7a680e235f43558344eb19a4a625b7 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 17 Jun 2016 11:51:55 -0400 Subject: [PATCH] Fix up missing notifications in invsrc --- awx/main/models/inventory.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 62930f2965..15edaf181d 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1184,14 +1184,21 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions): def notification_templates(self): base_notification_templates = NotificationTemplate.objects error_notification_templates = list(base_notification_templates - .filter(organization_notification_templates_for_errors=self.inventory.organization)) + .filter(unifiedjobtemplate_notification_templates_for_errors__in=[self])) success_notification_templates = list(base_notification_templates - .filter(organization_notification_templates_for_success=self.inventory.organization)) + .filter(unifiedjobtemplate_notification_templates_for_success__in=[self])) any_notification_templates = list(base_notification_templates - .filter(organization_notification_templates_for_any=self.inventory.organization)) - return dict(error=error_notification_templates, - success=success_notification_templates, - any=any_notification_templates) + .filter(unifiedjobtemplate_notification_templates_for_any__in=[self])) + if self.inventory.organization is not None: + error_notification_templates = set(error_notification_templates + list(base_notification_templates + .filter(organization_notification_templates_for_errors=self.inventory.organization))) + success_notification_templates = set(success_notification_templates + list(base_notification_templates + .filter(organization_notification_templates_for_success=self.inventory.organization))) + any_notification_templates = set(any_notification_templates + list(base_notification_templates + .filter(organization_notification_templates_for_any=self.inventory.organization))) + return dict(error=list(error_notification_templates), + success=list(success_notification_templates), + any=list(any_notification_templates)) def clean_source(self): source = self.source