Update ad_hoc_commands.py

refactoring code with set comprehension which is more concise and efficient
This commit is contained in:
zzj 2022-01-20 18:50:33 +08:00 committed by GitHub
parent e63ce9ed08
commit 16d39bb72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: