Add messages field

This commit is contained in:
Jim Ladd
2019-08-14 10:25:25 -07:00
parent efbaf46179
commit cb411cc3be
4 changed files with 35 additions and 1 deletions

View File

@@ -4125,7 +4125,8 @@ class NotificationTemplateSerializer(BaseSerializer):
class Meta:
model = NotificationTemplate
fields = ('*', 'organization', 'notification_type', 'notification_configuration')
fields = ('*', 'organization', 'notification_type', 'notification_configuration', 'messages')
type_map = {"string": (str,),
"int": (int,),

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-06-10 16:56
from __future__ import unicode_literals
from django.db import migrations, models
import awx.main.fields
class Migration(migrations.Migration):
dependencies = [
('main', '0082_v360_webhook_http_method'),
]
operations = [
migrations.AddField(
model_name='notificationtemplate',
name='messages',
field=awx.main.fields.JSONField(default=dict,
help_text='Optional custom messages for notification template.',
null=True,
blank=True),
),
]

View File

@@ -68,6 +68,12 @@ class NotificationTemplate(CommonModelNameNotUnique):
notification_configuration = JSONField(blank=False)
messages = JSONField(
null=True,
blank=True,
default=dict,
help_text=_('Optional custom messages for notification template.'))
def get_absolute_url(self, request=None):
return reverse('api:notification_template_detail', kwargs={'pk': self.pk}, request=request)

View File

@@ -42,6 +42,8 @@ def test_basic_parameterization(get, post, user, organization):
assert 'notification_configuration' in response.data
assert 'url' in response.data['notification_configuration']
assert 'headers' in response.data['notification_configuration']
assert 'messages' in response.data
assert response.data['messages'] == {'started': None, 'success': None, 'error': None}
@pytest.mark.django_db