From 16d39bb72be3f9562ed5cae11db2931f62397194 Mon Sep 17 00:00:00 2001 From: zzj <29055749+zjzh@users.noreply.github.com> Date: Thu, 20 Jan 2022 18:50:33 +0800 Subject: [PATCH] Update ad_hoc_commands.py refactoring code with set comprehension which is more concise and efficient --- awx/main/models/ad_hoc_commands.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index 48273c983b..f4065e473d 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -160,9 +160,7 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin): @property def notification_templates(self): - all_orgs = set() - for h in self.hosts.all(): - all_orgs.add(h.inventory.organization) + all_orgs = {h.inventory.organization for h in self.hosts.all()} active_templates = dict(error=set(), success=set(), started=set()) base_notification_templates = NotificationTemplate.objects for org in all_orgs: