From 1881af8e7759b453685c4150976ceab1734504be Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 2 Jun 2016 14:59:58 -0400 Subject: [PATCH] Fix passively creation of notification templates Passively creating notification templates on m2m endpoints was failing serializer validation due to a bug trying to look up the related object. In reality that check should only happen when the view is the NotificationTemplateDetail view. --- awx/api/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 2d0de18886..104eb8a521 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2369,12 +2369,13 @@ class NotificationTemplateSerializer(BaseSerializer): return d def validate(self, attrs): + from awx.api.views import NotificationTemplateDetail notification_class = NotificationTemplate.CLASS_FOR_NOTIFICATION_TYPE[attrs['notification_type']] missing_fields = [] incorrect_type_fields = [] if 'notification_configuration' not in attrs: return attrs - if self.context['view'].kwargs: + if self.context['view'].kwargs and isinstance(self.context['view'], NotificationTemplateDetail): object_actual = self.context['view'].get_object() else: object_actual = None