mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 02:01:01 -03:30
Merge pull request #2726 from ryanpetrello/fix-2690
prevent host deletion when the related inventory is pending deletion
This commit is contained in:
@@ -2251,6 +2251,12 @@ class HostDetail(RelatedJobsPreventDeleteMixin, ControlledByScmMixin, RetrieveUp
|
|||||||
model = Host
|
model = Host
|
||||||
serializer_class = HostSerializer
|
serializer_class = HostSerializer
|
||||||
|
|
||||||
|
def delete(self, request, *args, **kwargs):
|
||||||
|
if self.get_object().inventory.pending_deletion:
|
||||||
|
return Response({"error": _("The inventory for this host is already being deleted.")},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
return super(HostDetail, self).delete(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class HostAnsibleFactsDetail(RetrieveAPIView):
|
class HostAnsibleFactsDetail(RetrieveAPIView):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user