diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 7963c06f5ae2..381883b81ded 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1246,7 +1246,6 @@ def get_related(self, obj): applications = self.reverse('api:organization_applications_list', kwargs={'pk': obj.pk}), activity_stream = self.reverse('api:organization_activity_stream_list', kwargs={'pk': obj.pk}), notification_templates = self.reverse('api:organization_notification_templates_list', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:organization_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:organization_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:organization_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:organization_notification_templates_error_list', kwargs={'pk': obj.pk}), @@ -1353,7 +1352,6 @@ def get_related(self, obj): scm_inventory_sources = self.reverse('api:project_scm_inventory_sources', kwargs={'pk': obj.pk}), schedules = self.reverse('api:project_schedules_list', kwargs={'pk': obj.pk}), activity_stream = self.reverse('api:project_activity_stream_list', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:project_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:project_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:project_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:project_notification_templates_error_list', kwargs={'pk': obj.pk}), @@ -1972,7 +1970,6 @@ def get_related(self, obj): activity_stream = self.reverse('api:inventory_source_activity_stream_list', kwargs={'pk': obj.pk}), hosts = self.reverse('api:inventory_source_hosts_list', kwargs={'pk': obj.pk}), groups = self.reverse('api:inventory_source_groups_list', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:inventory_source_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:inventory_source_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:inventory_source_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:inventory_source_notification_templates_error_list', kwargs={'pk': obj.pk}), @@ -2795,7 +2792,6 @@ def get_related(self, obj): schedules = self.reverse('api:job_template_schedules_list', kwargs={'pk': obj.pk}), activity_stream = self.reverse('api:job_template_activity_stream_list', kwargs={'pk': obj.pk}), launch = self.reverse('api:job_template_launch', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:job_template_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:job_template_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:job_template_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:job_template_notification_templates_error_list', kwargs={'pk': obj.pk}), @@ -3208,7 +3204,6 @@ def get_related(self, obj): jobs = self.reverse('api:system_job_template_jobs_list', kwargs={'pk': obj.pk}), schedules = self.reverse('api:system_job_template_schedules_list', kwargs={'pk': obj.pk}), launch = self.reverse('api:system_job_template_launch', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:system_job_template_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:system_job_template_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:system_job_template_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:system_job_template_notification_templates_error_list', kwargs={'pk': obj.pk}), @@ -3276,7 +3271,6 @@ def get_related(self, obj): workflow_nodes = self.reverse('api:workflow_job_template_workflow_nodes_list', kwargs={'pk': obj.pk}), labels = self.reverse('api:workflow_job_template_label_list', kwargs={'pk': obj.pk}), activity_stream = self.reverse('api:workflow_job_template_activity_stream_list', kwargs={'pk': obj.pk}), - notification_templates_any = self.reverse('api:workflow_job_template_notification_templates_any_list', kwargs={'pk': obj.pk}), notification_templates_started = self.reverse('api:workflow_job_template_notification_templates_started_list', kwargs={'pk': obj.pk}), notification_templates_success = self.reverse('api:workflow_job_template_notification_templates_success_list', kwargs={'pk': obj.pk}), notification_templates_error = self.reverse('api:workflow_job_template_notification_templates_error_list', kwargs={'pk': obj.pk}), diff --git a/awx/api/urls/inventory_source.py b/awx/api/urls/inventory_source.py index e20362b52301..98c65d77bc20 100644 --- a/awx/api/urls/inventory_source.py +++ b/awx/api/urls/inventory_source.py @@ -30,8 +30,6 @@ url(r'^(?P[0-9]+)/credentials/$', InventorySourceCredentialsList.as_view(), name='inventory_source_credentials_list'), url(r'^(?P[0-9]+)/groups/$', InventorySourceGroupsList.as_view(), name='inventory_source_groups_list'), url(r'^(?P[0-9]+)/hosts/$', InventorySourceHostsList.as_view(), name='inventory_source_hosts_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', InventorySourceNotificationTemplatesAnyList.as_view(), - name='inventory_source_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_started/$', InventorySourceNotificationTemplatesStartedList.as_view(), name='inventory_source_notification_templates_started_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', InventorySourceNotificationTemplatesErrorList.as_view(), diff --git a/awx/api/urls/job_template.py b/awx/api/urls/job_template.py index d9c755e731a6..3d61094eb46d 100644 --- a/awx/api/urls/job_template.py +++ b/awx/api/urls/job_template.py @@ -35,8 +35,6 @@ url(r'^(?P[0-9]+)/schedules/$', JobTemplateSchedulesList.as_view(), name='job_template_schedules_list'), url(r'^(?P[0-9]+)/survey_spec/$', JobTemplateSurveySpec.as_view(), name='job_template_survey_spec'), url(r'^(?P[0-9]+)/activity_stream/$', JobTemplateActivityStreamList.as_view(), name='job_template_activity_stream_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', JobTemplateNotificationTemplatesAnyList.as_view(), - name='job_template_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_started/$', JobTemplateNotificationTemplatesStartedList.as_view(), name='job_template_notification_templates_started_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', JobTemplateNotificationTemplatesErrorList.as_view(), diff --git a/awx/api/urls/organization.py b/awx/api/urls/organization.py index af04f1fc773c..2fed9ca97faf 100644 --- a/awx/api/urls/organization.py +++ b/awx/api/urls/organization.py @@ -38,8 +38,6 @@ url(r'^(?P[0-9]+)/credentials/$', OrganizationCredentialList.as_view(), name='organization_credential_list'), url(r'^(?P[0-9]+)/activity_stream/$', OrganizationActivityStreamList.as_view(), name='organization_activity_stream_list'), url(r'^(?P[0-9]+)/notification_templates/$', OrganizationNotificationTemplatesList.as_view(), name='organization_notification_templates_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', OrganizationNotificationTemplatesAnyList.as_view(), - name='organization_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_started/$', OrganizationNotificationTemplatesStartedList.as_view(), name='organization_notification_templates_started_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', OrganizationNotificationTemplatesErrorList.as_view(), diff --git a/awx/api/urls/project.py b/awx/api/urls/project.py index a37bf0cefb3d..192c41f54a7f 100644 --- a/awx/api/urls/project.py +++ b/awx/api/urls/project.py @@ -35,7 +35,6 @@ url(r'^(?P[0-9]+)/project_updates/$', ProjectUpdatesList.as_view(), name='project_updates_list'), url(r'^(?P[0-9]+)/activity_stream/$', ProjectActivityStreamList.as_view(), name='project_activity_stream_list'), url(r'^(?P[0-9]+)/schedules/$', ProjectSchedulesList.as_view(), name='project_schedules_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', ProjectNotificationTemplatesAnyList.as_view(), name='project_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', ProjectNotificationTemplatesErrorList.as_view(), name='project_notification_templates_error_list'), url(r'^(?P[0-9]+)/notification_templates_success/$', ProjectNotificationTemplatesSuccessList.as_view(), name='project_notification_templates_success_list'), diff --git a/awx/api/urls/system_job_template.py b/awx/api/urls/system_job_template.py index 70c0c698360b..9886c4c14a8b 100644 --- a/awx/api/urls/system_job_template.py +++ b/awx/api/urls/system_job_template.py @@ -22,8 +22,6 @@ url(r'^(?P[0-9]+)/launch/$', SystemJobTemplateLaunch.as_view(), name='system_job_template_launch'), url(r'^(?P[0-9]+)/jobs/$', SystemJobTemplateJobsList.as_view(), name='system_job_template_jobs_list'), url(r'^(?P[0-9]+)/schedules/$', SystemJobTemplateSchedulesList.as_view(), name='system_job_template_schedules_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', SystemJobTemplateNotificationTemplatesAnyList.as_view(), - name='system_job_template_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_started/$', SystemJobTemplateNotificationTemplatesStartedList.as_view(), name='system_job_template_notification_templates_started_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', SystemJobTemplateNotificationTemplatesErrorList.as_view(), diff --git a/awx/api/urls/workflow_job_template.py b/awx/api/urls/workflow_job_template.py index 67ac690b6022..5429e0fc3efd 100644 --- a/awx/api/urls/workflow_job_template.py +++ b/awx/api/urls/workflow_job_template.py @@ -33,8 +33,6 @@ url(r'^(?P[0-9]+)/survey_spec/$', WorkflowJobTemplateSurveySpec.as_view(), name='workflow_job_template_survey_spec'), url(r'^(?P[0-9]+)/workflow_nodes/$', WorkflowJobTemplateWorkflowNodesList.as_view(), name='workflow_job_template_workflow_nodes_list'), url(r'^(?P[0-9]+)/activity_stream/$', WorkflowJobTemplateActivityStreamList.as_view(), name='workflow_job_template_activity_stream_list'), - url(r'^(?P[0-9]+)/notification_templates_any/$', WorkflowJobTemplateNotificationTemplatesAnyList.as_view(), - name='workflow_job_template_notification_templates_any_list'), url(r'^(?P[0-9]+)/notification_templates_started/$', WorkflowJobTemplateNotificationTemplatesStartedList.as_view(), name='workflow_job_template_notification_templates_started_list'), url(r'^(?P[0-9]+)/notification_templates_error/$', WorkflowJobTemplateNotificationTemplatesErrorList.as_view(), diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index b494986ac8e6..092675267dd9 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -748,7 +748,6 @@ class ProjectNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView): model = models.NotificationTemplate serializer_class = serializers.NotificationTemplateSerializer parent_model = models.Project - relationship = 'notification_templates_any' class ProjectNotificationTemplatesStartedList(ProjectNotificationTemplatesAnyList): @@ -2102,7 +2101,6 @@ class InventorySourceNotificationTemplatesAnyList(SubListCreateAttachDetachAPIVi model = models.NotificationTemplate serializer_class = serializers.NotificationTemplateSerializer parent_model = models.InventorySource - relationship = 'notification_templates_any' def post(self, request, *args, **kwargs): parent = self.get_parent_object() @@ -2631,7 +2629,6 @@ class JobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView): model = models.NotificationTemplate serializer_class = serializers.NotificationTemplateSerializer parent_model = models.JobTemplate - relationship = 'notification_templates_any' class JobTemplateNotificationTemplatesStartedList(JobTemplateNotificationTemplatesAnyList): @@ -3238,7 +3235,6 @@ class WorkflowJobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachA model = models.NotificationTemplate serializer_class = serializers.NotificationTemplateSerializer parent_model = models.WorkflowJobTemplate - relationship = 'notification_templates_any' class WorkflowJobTemplateNotificationTemplatesStartedList(WorkflowJobTemplateNotificationTemplatesAnyList): @@ -3414,7 +3410,6 @@ class SystemJobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachAPI model = models.NotificationTemplate serializer_class = serializers.NotificationTemplateSerializer parent_model = models.SystemJobTemplate - relationship = 'notification_templates_any' class SystemJobTemplateNotificationTemplatesStartedList(SystemJobTemplateNotificationTemplatesAnyList): diff --git a/awx/api/views/organization.py b/awx/api/views/organization.py index de5ef998cd0a..6213e14f632f 100644 --- a/awx/api/views/organization.py +++ b/awx/api/views/organization.py @@ -178,7 +178,6 @@ class OrganizationNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView) model = NotificationTemplate serializer_class = NotificationTemplateSerializer parent_model = Organization - relationship = 'notification_templates_any' class OrganizationNotificationTemplatesStartedList(OrganizationNotificationTemplatesAnyList): diff --git a/awx/main/migrations/0081_v360_notify_on_start.py b/awx/main/migrations/0081_v360_notify_on_start.py index 7fc783d20d47..f8578e62273f 100644 --- a/awx/main/migrations/0081_v360_notify_on_start.py +++ b/awx/main/migrations/0081_v360_notify_on_start.py @@ -22,4 +22,13 @@ class Migration(migrations.Migration): name='notification_templates_started', field=models.ManyToManyField(blank=True, related_name='unifiedjobtemplate_notification_templates_for_started', to='main.NotificationTemplate'), ), +# migrations.RunPython() stuff goes in here + migrations.RemoveField( + model_name='organization', + name='notification_templates_any', + ), + migrations.RemoveField( + model_name='unifiedjobtemplate', + name='notification_templates_any', + ), ] diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index c843b9f57751..287955f42eff 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -163,7 +163,7 @@ def notification_templates(self): all_orgs.add(h.inventory.organization) active_templates = dict(error=set(), success=set(), - any=set()) + started=set()) base_notification_templates = NotificationTemplate.objects for org in all_orgs: for templ in base_notification_templates.filter(organization_notification_templates_for_errors=org): @@ -172,10 +172,7 @@ def notification_templates(self): active_templates['success'].add(templ) for templ in base_notification_templates.filter(organization_notification_templates_for_started=org): active_templates['started'].add(templ) - for templ in base_notification_templates.filter(organization_notification_templates_for_any=org): - active_templates['any'].add(templ) active_templates['error'] = list(active_templates['error']) - active_templates['any'] = list(active_templates['any']) active_templates['success'] = list(active_templates['success']) active_templates['started'] = list(active_templates['started']) return active_templates diff --git a/awx/main/models/base.py b/awx/main/models/base.py index ec36ec8785d0..9925dc6049e4 100644 --- a/awx/main/models/base.py +++ b/awx/main/models/base.py @@ -392,13 +392,6 @@ class Meta: related_name='%(class)s_notification_templates_for_started' ) - notification_templates_any = models.ManyToManyField( - "NotificationTemplate", - blank=True, - related_name='%(class)s_notification_templates_for_any' - ) - - def prevent_search(relation): """ diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 9301c63c1d90..5c1f4ef8eb16 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1623,8 +1623,6 @@ def notification_templates(self): .filter(unifiedjobtemplate_notification_templates_for_started__in=[self])) success_notification_templates = list(base_notification_templates .filter(unifiedjobtemplate_notification_templates_for_success__in=[self])) - any_notification_templates = list(base_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))) @@ -1632,12 +1630,9 @@ def notification_templates(self): .filter(organization_notification_templates_for_started=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), started=list(started_notification_templates), - success=list(success_notification_templates), - any=list(any_notification_templates)) + success=list(success_notification_templates)) def clean_source(self): # TODO: remove in 3.3 source = self.source diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index f20d074ead12..59b26c66e596 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -439,8 +439,6 @@ def notification_templates(self): unifiedjobtemplate_notification_templates_for_started__in=[self, self.project])) success_notification_templates = list(base_notification_templates.filter( unifiedjobtemplate_notification_templates_for_success__in=[self, self.project])) - any_notification_templates = list(base_notification_templates.filter( - unifiedjobtemplate_notification_templates_for_any__in=[self, self.project])) # Get Organization NotificationTemplates if self.project is not None and self.project.organization is not None: error_notification_templates = set(error_notification_templates + list(base_notification_templates.filter( @@ -449,12 +447,9 @@ def notification_templates(self): organization_notification_templates_for_started=self.project.organization))) success_notification_templates = set(success_notification_templates + list(base_notification_templates.filter( organization_notification_templates_for_success=self.project.organization))) - any_notification_templates = set(any_notification_templates + list(base_notification_templates.filter( - organization_notification_templates_for_any=self.project.organization))) return dict(error=list(error_notification_templates), started=list(started_notification_templates), - success=list(success_notification_templates), - any=list(any_notification_templates)) + success=list(success_notification_templates)) ''' RelatedJobsMixin @@ -1144,12 +1139,9 @@ def notification_templates(self): .filter(unifiedjobtemplate_notification_templates_for_started__in=[self])) success_notification_templates = list(base_notification_templates .filter(unifiedjobtemplate_notification_templates_for_success__in=[self])) - any_notification_templates = list(base_notification_templates - .filter(unifiedjobtemplate_notification_templates_for_any__in=[self])) return dict(error=list(error_notification_templates), started=list(started_notification_templates), - success=list(success_notification_templates), - any=list(any_notification_templates)) + success=list(success_notification_templates)) def _accept_or_ignore_job_kwargs(self, _exclude_errors=None, **kwargs): extra_data = kwargs.pop('extra_vars', {}) diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index c4ba9a7f96e0..eb9121fd2104 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -235,18 +235,16 @@ def send_notification_templates(self, status_str): logger.warn("No notification template defined for emitting notification") notification_templates = None if notification_templates: - all_notification_templates = set() - if status_str != 'running': - all_notification_templates.update(notification_templates.get('any', [])) - notification_template_type = 'any' - elif status_str == 'succeeded': + if status_str == 'succeeded': notification_template_type = 'success' elif status_str == 'running': notification_template_type = 'started' else: notification_template_type = 'error' - all_notification_templates.update(notification_templates.get(notification_template_type, [])) + all_notification_templates = set(notification_templates.get(notification_template_type, [])) if len(all_notification_templates): + # if status_str != 'running': + # all_notification_templates.update(notification_templates.get('any', [])) try: (notification_subject, notification_body) = getattr(self, 'build_notification_%s_message' % status_str)() except AttributeError: diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 9da401a909f1..c86b08421d48 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -415,8 +415,6 @@ def notification_templates(self): .filter(unifiedjobtemplate_notification_templates_for_started=self)) success_notification_templates = list(base_notification_templates .filter(unifiedjobtemplate_notification_templates_for_success=self)) - any_notification_templates = list(base_notification_templates - .filter(unifiedjobtemplate_notification_templates_for_any=self)) # Get Organization NotificationTemplates if self.organization is not None: error_notification_templates = set(error_notification_templates + @@ -428,13 +426,9 @@ def notification_templates(self): success_notification_templates = set(success_notification_templates + list(base_notification_templates .filter(organization_notification_templates_for_success=self.organization))) - any_notification_templates = set(any_notification_templates + - list(base_notification_templates - .filter(organization_notification_templates_for_any=self.organization))) return dict(error=list(error_notification_templates), started=list(started_notification_templates), - success=list(success_notification_templates), - any=list(any_notification_templates)) + success=list(success_notification_templates)) def get_absolute_url(self, request=None): return reverse('api:project_detail', kwargs={'pk': self.pk}, request=request) diff --git a/awx/main/models/workflow.py b/awx/main/models/workflow.py index 3be0938058e1..e5f36054ff31 100644 --- a/awx/main/models/workflow.py +++ b/awx/main/models/workflow.py @@ -423,12 +423,9 @@ def notification_templates(self): .filter(unifiedjobtemplate_notification_templates_for_started__in=[self])) success_notification_templates = list(base_notification_templates .filter(unifiedjobtemplate_notification_templates_for_success__in=[self])) - any_notification_templates = list(base_notification_templates - .filter(unifiedjobtemplate_notification_templates_for_any__in=[self])) return dict(error=list(error_notification_templates), started=list(started_notification_templates), - success=list(success_notification_templates), - any=list(any_notification_templates)) + success=list(success_notification_templates)) def create_unified_job(self, **kwargs): workflow_job = super(WorkflowJobTemplate, self).create_unified_job(**kwargs) diff --git a/awx/main/tests/functional/api/test_inventory.py b/awx/main/tests/functional/api/test_inventory.py index 78827dbe3407..9f7688ebf375 100644 --- a/awx/main/tests/functional/api/test_inventory.py +++ b/awx/main/tests/functional/api/test_inventory.py @@ -42,9 +42,10 @@ def test_inventory_source_notification_on_cloud_only(get, post, inventory_source not_is = inventory_source_factory("not_ec2") - url = reverse('api:inventory_source_notification_templates_any_list', kwargs={'pk': cloud_is.id}) - response = post(url, dict(id=notification_template.id), u) - assert response.status_code == 204 + # Delete the below portion? + # url = reverse('api:inventory_source_notification_templates_any_list', kwargs={'pk': cloud_is.id}) + # response = post(url, dict(id=notification_template.id), u) + # assert response.status_code == 204 url = reverse('api:inventory_source_notification_templates_success_list', kwargs={'pk': not_is.id}) response = post(url, dict(id=notification_template.id), u) diff --git a/awx/main/tests/functional/test_notifications.py b/awx/main/tests/functional/test_notifications.py index 5c2bf74d5a8c..fb209f5e7737 100644 --- a/awx/main/tests/functional/test_notifications.py +++ b/awx/main/tests/functional/test_notifications.py @@ -92,18 +92,19 @@ def test_inherited_notification_templates(get, post, user, organization, project isrc.save() jt = JobTemplate.objects.create(name='test', inventory=i, project=project, playbook='debug.yml') jt.save() - url = reverse('api:organization_notification_templates_any_list', kwargs={'pk': organization.id}) - response = post(url, dict(id=notification_templates[0]), u) - assert response.status_code == 204 - url = reverse('api:project_notification_templates_any_list', kwargs={'pk': project.id}) - response = post(url, dict(id=notification_templates[1]), u) - assert response.status_code == 204 - url = reverse('api:job_template_notification_templates_any_list', kwargs={'pk': jt.id}) - response = post(url, dict(id=notification_templates[2]), u) - assert response.status_code == 204 - assert len(jt.notification_templates['any']) == 3 - assert len(project.notification_templates['any']) == 2 - assert len(isrc.notification_templates['any']) == 1 + # What can we replace the below tests with? + # url = reverse('api:organization_notification_templates_any_list', kwargs={'pk': organization.id}) + # response = post(url, dict(id=notification_templates[0]), u) + # assert response.status_code == 204 + # url = reverse('api:project_notification_templates_any_list', kwargs={'pk': project.id}) + # response = post(url, dict(id=notification_templates[1]), u) + # assert response.status_code == 204 + # url = reverse('api:job_template_notification_templates_any_list', kwargs={'pk': jt.id}) + # response = post(url, dict(id=notification_templates[2]), u) + # assert response.status_code == 204 + # assert len(jt.notification_templates['any']) == 3 + # assert len(project.notification_templates['any']) == 2 + # assert len(isrc.notification_templates['any']) == 1 @pytest.mark.django_db diff --git a/awx/main/tests/unit/api/serializers/test_inventory_serializers.py b/awx/main/tests/unit/api/serializers/test_inventory_serializers.py index 664f374483a7..a1191bea2c31 100644 --- a/awx/main/tests/unit/api/serializers/test_inventory_serializers.py +++ b/awx/main/tests/unit/api/serializers/test_inventory_serializers.py @@ -71,7 +71,7 @@ class TestInventorySourceSerializerGetRelated(object): 'activity_stream', 'notification_templates_error', 'notification_templates_success', - 'notification_templates_any', + 'notification_templates_started', 'inventory_updates', 'update', 'hosts', diff --git a/awx/main/tests/unit/api/serializers/test_job_template_serializers.py b/awx/main/tests/unit/api/serializers/test_job_template_serializers.py index 3e842a059829..698d27cb7c5c 100644 --- a/awx/main/tests/unit/api/serializers/test_job_template_serializers.py +++ b/awx/main/tests/unit/api/serializers/test_job_template_serializers.py @@ -50,7 +50,7 @@ class TestJobTemplateSerializerGetRelated(): 'schedules', 'activity_stream', 'launch', - 'notification_templates_any', + 'notification_templates_started', 'notification_templates_success', 'notification_templates_error', 'survey_spec', diff --git a/docs/notification_system.md b/docs/notification_system.md index 6b751beca325..7ef17d2cef2e 100644 --- a/docs/notification_system.md +++ b/docs/notification_system.md @@ -22,9 +22,7 @@ Notification templates assigned at certain levels will inherit notifications def ## Workflow -When a job starts, succeeds or fails, the running, error or success handler will pull a list of relevant notifications using the procedure defined above. It will then create a Notification object for each one containing relevant details about the job and then **sends** it to the destination (email addresses, slack channel(s), SMS numbers, etc.). These Notification objects are available as related resources on job types (Jobs, Inventory Updates, Project Updates), and also at `/api/v2/notifications`. You may also see what notifications have been sent from a notifications by examining its related resources. - -When a notification is associated to a job via the `/api/v2/.../notification_templates_any/` endpoint, it will send upon success OR fail, but _not_ on start. +When a job starts, succeeds or fails, the running, success or error handler, respectively, will pull a list of relevant notifications using the procedure defined above. It then creates a Notification Object for each one containing relevant details about the job and then **sends** it to the destination (email addresses, Slack channel(s), SMS numbers, etc.). These Notification objects are available as related resources on job types (Jobs, Inventory Updates, Project Updates), and also at `/api/v2/notifications`. You may also see what notifications have been sent by examining its related resources. Notifications can succeed or fail but that will _not_ cause its associated job to succeed or fail. The status of the notification can be viewed at its detail endpoint: `/api/v2/notifications/`