mirror of
https://github.com/ansible/awx.git
synced 2026-05-25 01:27:45 -02:30
Integrate unnecessary queries for better performance.
This commit is contained in:
@@ -1090,8 +1090,7 @@ class ProjectUpdateDetail(RetrieveDestroyAPIView):
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
for unified_job_node in obj.unified_job_nodes.all():
|
||||
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||
if obj.unified_job_nodes.filter(workflow_job__status__in=ACTIVE_STATES).exists():
|
||||
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||
return super(ProjectUpdateDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
@@ -2176,8 +2175,7 @@ class InventoryUpdateDetail(RetrieveDestroyAPIView):
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
for unified_job_node in obj.unified_job_nodes.all():
|
||||
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||
if obj.unified_job_nodes.filter(workflow_job__status__in=ACTIVE_STATES).exists():
|
||||
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||
return super(InventoryUpdateDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
@@ -2886,8 +2884,7 @@ class JobDetail(RetrieveUpdateDestroyAPIView):
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
for unified_job_node in obj.unified_job_nodes.all():
|
||||
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||
if obj.unified_job_nodes.filter(workflow_job__status__in=ACTIVE_STATES).exists():
|
||||
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||
return super(JobDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user