mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 03:30:02 -03:30
Delete created resource when it fails the relationship verification.
This commit is contained in:
@@ -412,6 +412,8 @@ class SubListCreateAttachDetachAPIView(SubListCreateAPIView):
|
|||||||
# Verify that the relationship to be added is valid.
|
# Verify that the relationship to be added is valid.
|
||||||
attach_errors = self.is_valid_relation(parent, sub)
|
attach_errors = self.is_valid_relation(parent, sub)
|
||||||
if attach_errors is not None:
|
if attach_errors is not None:
|
||||||
|
if created:
|
||||||
|
sub.delete()
|
||||||
return Response(attach_errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(attach_errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
# Attach the object to the collection.
|
# Attach the object to the collection.
|
||||||
|
|||||||
@@ -2669,8 +2669,10 @@ class WorkflowJobTemplateNodeChildrenBaseList(EnforceParentRelationshipMixin, Su
|
|||||||
related_nodes = getattr(workflow_node, node_type).all()
|
related_nodes = getattr(workflow_node, node_type).all()
|
||||||
for related_node in related_nodes:
|
for related_node in related_nodes:
|
||||||
graph.add_edge(workflow_node, related_node, node_type)
|
graph.add_edge(workflow_node, related_node, node_type)
|
||||||
if not find and parent == workflow_node and\
|
if (not find and
|
||||||
sub == related_node and self.relationship == node_type:
|
parent == workflow_node and
|
||||||
|
sub == related_node and
|
||||||
|
self.relationship == node_type):
|
||||||
find = True
|
find = True
|
||||||
if not find:
|
if not find:
|
||||||
graph.add_edge(parent, sub, self.relationship)
|
graph.add_edge(parent, sub, self.relationship)
|
||||||
|
|||||||
Reference in New Issue
Block a user