diff --git a/awx/api/serializers.py b/awx/api/serializers.py index ca454a0b1e..794ee938f6 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -4618,12 +4618,15 @@ class NotificationTemplateSerializer(BaseSerializer): object_actual = self.context['view'].get_object() else: object_actual = None - for field in notification_class.init_parameters: + for field, params in notification_class.init_parameters.items(): if field not in attrs['notification_configuration']: - missing_fields.append(field) - continue + if 'default' in params: + attrs['notification_configuration'][field] = params['default'] + else: + missing_fields.append(field) + continue field_val = attrs['notification_configuration'][field] - field_type = notification_class.init_parameters[field]['type'] + field_type = params['type'] expected_types = self.type_map[field_type] if not type(field_val) in expected_types: incorrect_type_fields.append((field, field_type)) diff --git a/awx/main/notifications/email_backend.py b/awx/main/notifications/email_backend.py index 6339519115..1b30b344bb 100644 --- a/awx/main/notifications/email_backend.py +++ b/awx/main/notifications/email_backend.py @@ -18,10 +18,11 @@ class CustomEmailBackend(EmailBackend): "use_ssl": {"label": "Use SSL", "type": "bool"}, "sender": {"label": "Sender Email", "type": "string"}, "recipients": {"label": "Recipient List", "type": "list"}, - "timeout": {"label": "Timeout", "type": "int"}} + "timeout": {"label": "Timeout", "type": "int", "default": 30}} recipient_parameter = "recipients" sender_parameter = "sender" + def format_body(self, body): if "body" in body: body_actual = body['body']