From 0c224df9ad56c5b5df0a80acc2bc68da029fafa2 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 11 Apr 2018 07:54:09 -0400 Subject: [PATCH] make deletion protection mixin work with inventories --- awx/api/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/api/views.py b/awx/api/views.py index 05c15b9243..1629173fba 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -203,6 +203,10 @@ class InstanceGroupMembershipMixin(object): class RelatedJobsPreventDeleteMixin(object): def perform_destroy(self, obj): + self.check_related_active_jobs(obj) + return super(RelatedJobsPreventDeleteMixin, self).perform_destroy(obj) + + def check_related_active_jobs(self, obj): active_jobs = obj.get_active_jobs() if len(active_jobs) > 0: raise ActiveJobConflict(active_jobs) @@ -213,7 +217,6 @@ class RelatedJobsPreventDeleteMixin(object): raise PermissionDenied(_( 'Related job {} is still processing events.' ).format(unified_job.log_format)) - return super(RelatedJobsPreventDeleteMixin, self).perform_destroy(obj) class ApiRootView(APIView): @@ -2085,6 +2088,7 @@ class InventoryDetail(RelatedJobsPreventDeleteMixin, ControlledByScmMixin, Retri obj = self.get_object() if not request.user.can_access(self.model, 'delete', obj): raise PermissionDenied() + self.check_related_active_jobs(obj) # related jobs mixin try: obj.schedule_deletion(getattr(request.user, 'id', None)) return Response(status=status.HTTP_202_ACCEPTED)