1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Update Organization Notification Template subclass, move success/fail wfj notification trigger

This commit is contained in:
beeankha 2019-06-04 13:08:22 -04:00
parent dd372548a9
commit 68fe23d8b7
2 changed files with 6 additions and 18 deletions

View File

@ -181,27 +181,18 @@ class OrganizationNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView)
relationship = 'notification_templates_any'
class OrganizationNotificationTemplatesStartedList(SubListCreateAttachDetachAPIView):
class OrganizationNotificationTemplatesStartedList(OrganizationNotificationTemplatesAnyList):
model = NotificationTemplate
serializer_class = NotificationTemplateSerializer
parent_model = Organization
relationship = 'notification_templates_started'
class OrganizationNotificationTemplatesErrorList(SubListCreateAttachDetachAPIView):
class OrganizationNotificationTemplatesErrorList(OrganizationNotificationTemplatesAnyList):
model = NotificationTemplate
serializer_class = NotificationTemplateSerializer
parent_model = Organization
relationship = 'notification_templates_error'
class OrganizationNotificationTemplatesSuccessList(SubListCreateAttachDetachAPIView):
class OrganizationNotificationTemplatesSuccessList(OrganizationNotificationTemplatesAnyList):
model = NotificationTemplate
serializer_class = NotificationTemplateSerializer
parent_model = Organization
relationship = 'notification_templates_success'

View File

@ -193,6 +193,8 @@ class TaskManager():
status_changed = True
if status_changed:
workflow_job.websocket_emit_status(workflow_job.status)
# Operations whose queries rely on modifications made during the atomic scheduling session
connection.on_commit(lambda: workflow_job.send_notification_templates('succeeded' if workflow_job.status == 'successful' else 'failed'))
if workflow_job.spawned_by_workflow:
schedule_task_manager()
return result
@ -582,10 +584,5 @@ class TaskManager():
logger.debug("Not running scheduler, another task holds lock")
return
logger.debug("Starting Scheduler")
with task_manager_bulk_reschedule():
finished_wfjs = self._schedule()
# Operations whose queries rely on modifications made during the atomic scheduling session
for wfj in WorkflowJob.objects.filter(id__in=finished_wfjs):
wfj.send_notification_templates('succeeded' if wfj.status == 'successful' else 'failed')
self._schedule()