Implement notification serializer and validations

This commit is contained in:
Matthew Jones
2016-02-04 11:31:34 -05:00
parent 172207cd4b
commit 319deffc18
2 changed files with 22 additions and 1 deletions

View File

@@ -12,7 +12,7 @@ from rest_framework import serializers
from rest_framework.request import clone_request
# Ansible Tower
from awx.main.models import InventorySource
from awx.main.models import InventorySource, NotificationTemplate
class Metadata(metadata.SimpleMetadata):
@@ -55,6 +55,12 @@ class Metadata(metadata.SimpleMetadata):
get_group_by_choices = getattr(InventorySource, 'get_%s_group_by_choices' % cp)
field_info['%s_group_by_choices' % cp] = get_group_by_choices()
# Special handling of notification configuration where the required properties
# are conditional on the type selected.
if field.field_name == 'notification_configuration':
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
field_info[notification_type_name] = notification_type_class.init_parameters
# Update type of fields returned...
if field.field_name == 'type':
field_info['type'] = 'multiple choice'