mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-07 16:41:48 -05:00
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.
|
||||
attach_errors = self.is_valid_relation(parent, sub)
|
||||
if attach_errors is not None:
|
||||
if created:
|
||||
sub.delete()
|
||||
return Response(attach_errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Attach the object to the collection.
|
||||
|
||||
Reference in New Issue
Block a user