mirror of
https://github.com/ansible/awx.git
synced 2026-05-05 16:37:37 -02:30
Fix an ommitted fields 500 error
If organization or notification_template is omitted entirely from the POST for a new item then a 500 error would be raised
This commit is contained in:
@@ -2427,10 +2427,14 @@ class NotificationTemplateSerializer(BaseSerializer):
|
|||||||
notification_type = attrs['notification_type']
|
notification_type = attrs['notification_type']
|
||||||
elif self.instance:
|
elif self.instance:
|
||||||
notification_type = self.instance.notification_type
|
notification_type = self.instance.notification_type
|
||||||
|
else:
|
||||||
|
notification_type = None
|
||||||
if 'organization' in attrs:
|
if 'organization' in attrs:
|
||||||
organization = attrs['organization']
|
organization = attrs['organization']
|
||||||
elif self.instance:
|
elif self.instance:
|
||||||
organization = self.instance.organization
|
organization = self.instance.organization
|
||||||
|
else:
|
||||||
|
organization = None
|
||||||
if not notification_type:
|
if not notification_type:
|
||||||
raise serializers.ValidationError('Missing required fields for Notification Configuration: notification_type')
|
raise serializers.ValidationError('Missing required fields for Notification Configuration: notification_type')
|
||||||
if not organization:
|
if not organization:
|
||||||
|
|||||||
Reference in New Issue
Block a user