diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index 39cea4917b..ee75387f2f 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -1,6 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved. +from copy import deepcopy import logging from django.db import models @@ -122,7 +123,12 @@ class NotificationTemplate(CommonModelNameNotUnique): if not isinstance(recipients, list): recipients = [recipients] sender = self.notification_configuration.pop(self.notification_class.sender_parameter, None) - backend_obj = self.notification_class(**self.notification_configuration) + notification_configuration = deepcopy(self.notification_configuration) + for field, params in self.notification_class.init_parameters.items(): + if field not in notification_configuration: + if 'default' in params: + notification_configuration[field] = params['default'] + backend_obj = self.notification_class(**notification_configuration) notification_obj = EmailMessage(subject, backend_obj.format_body(body), sender, recipients) with set_environ(**settings.AWX_TASK_ENV): return backend_obj.send_messages([notification_obj]) diff --git a/awx/ui/client/src/notifications/edit/edit.controller.js b/awx/ui/client/src/notifications/edit/edit.controller.js index e49b95dd3c..ff1c3de490 100644 --- a/awx/ui/client/src/notifications/edit/edit.controller.js +++ b/awx/ui/client/src/notifications/edit/edit.controller.js @@ -86,6 +86,10 @@ export default ['Rest', 'Wait', } } else { + if (data.notification_configuration.timeout === null || + !data.notification_configuration.timeout){ + $scope.timeout = 30; + } if (data.notification_configuration[fld]) { $scope[fld] = data.notification_configuration[fld]; master[fld] = data.notification_configuration[fld]; @@ -193,7 +197,11 @@ export default ['Rest', 'Wait', $scope[subFldName] = null; $scope.notification_template_form[subFldName].$setPristine(); } - } else { + } + if ($scope.timeout === null || !$scope.timeout) { + $scope.timeout = 30; + } + else { $scope[fld] = null; $scope.notification_template_form[fld].$setPristine(); }