mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Merge pull request #3796 from jangsutsr/3526_prevent_job_deletion_during_workflow_run
Add destory sanity checks to prevent UJ deletion during underlying workflow run
This commit is contained in:
commit
7348acdcfc
@ -70,6 +70,7 @@ from awx.api.renderers import * # noqa
|
||||
from awx.api.serializers import * # noqa
|
||||
from awx.api.metadata import RoleMetadata
|
||||
from awx.main.consumers import emit_channel_notification
|
||||
from awx.main.models.unified_jobs import ACTIVE_STATES
|
||||
|
||||
logger = logging.getLogger('awx.api.views')
|
||||
|
||||
@ -1089,6 +1090,12 @@ class ProjectUpdateDetail(RetrieveDestroyAPIView):
|
||||
serializer_class = ProjectUpdateSerializer
|
||||
new_in_13 = True
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
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)
|
||||
|
||||
class ProjectUpdateCancel(RetrieveAPIView):
|
||||
|
||||
model = ProjectUpdate
|
||||
@ -2167,6 +2174,12 @@ class InventoryUpdateDetail(RetrieveDestroyAPIView):
|
||||
serializer_class = InventoryUpdateSerializer
|
||||
new_in_14 = True
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
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)
|
||||
|
||||
class InventoryUpdateCancel(RetrieveAPIView):
|
||||
|
||||
model = InventoryUpdate
|
||||
@ -2924,6 +2937,12 @@ class JobDetail(RetrieveUpdateDestroyAPIView):
|
||||
return self.http_method_not_allowed(request, *args, **kwargs)
|
||||
return super(JobDetail, self).update(request, *args, **kwargs)
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
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)
|
||||
|
||||
class JobLabelList(SubListAPIView):
|
||||
|
||||
model = Label
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user