mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 07:47:44 -02:30
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:
@@ -2369,12 +2369,13 @@ class NotificationTemplateSerializer(BaseSerializer):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
from awx.api.views import NotificationTemplateDetail
|
||||||
notification_class = NotificationTemplate.CLASS_FOR_NOTIFICATION_TYPE[attrs['notification_type']]
|
notification_class = NotificationTemplate.CLASS_FOR_NOTIFICATION_TYPE[attrs['notification_type']]
|
||||||
missing_fields = []
|
missing_fields = []
|
||||||
incorrect_type_fields = []
|
incorrect_type_fields = []
|
||||||
if 'notification_configuration' not in attrs:
|
if 'notification_configuration' not in attrs:
|
||||||
return 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()
|
object_actual = self.context['view'].get_object()
|
||||||
else:
|
else:
|
||||||
object_actual = None
|
object_actual = None
|
||||||
|
|||||||
Reference in New Issue
Block a user