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

Merge pull request #3501 from beeankha/timeout_upgrade

Upgrade Old Email Timeout Notifications

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-04-04 13:23:43 +00:00 committed by GitHub
commit e3f10ebd65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -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])

View File

@ -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();
}