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:
Matthew Jones 2016-07-13 10:45:17 -04:00
parent 99bd6ac38c
commit e9a0f41152

View File

@ -2427,10 +2427,14 @@ class NotificationTemplateSerializer(BaseSerializer):
notification_type = attrs['notification_type']
elif self.instance:
notification_type = self.instance.notification_type
else:
notification_type = None
if 'organization' in attrs:
organization = attrs['organization']
elif self.instance:
organization = self.instance.organization
else:
organization = None
if not notification_type:
raise serializers.ValidationError('Missing required fields for Notification Configuration: notification_type')
if not organization: