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.
This commit is contained in:
Matthew Jones 2016-06-02 14:59:58 -04:00
parent 0591647333
commit 1881af8e77

View File

@ -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