mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 02:47:35 -02:30
Use ACTIVE_STATES and change error message text.
This commit is contained in:
@@ -69,6 +69,7 @@ from awx.api.renderers import * # noqa
|
|||||||
from awx.api.serializers import * # noqa
|
from awx.api.serializers import * # noqa
|
||||||
from awx.api.metadata import RoleMetadata
|
from awx.api.metadata import RoleMetadata
|
||||||
from awx.main.consumers import emit_channel_notification
|
from awx.main.consumers import emit_channel_notification
|
||||||
|
from awx.main.models.unified_jobs import ACTIVE_STATES
|
||||||
|
|
||||||
logger = logging.getLogger('awx.api.views')
|
logger = logging.getLogger('awx.api.views')
|
||||||
|
|
||||||
@@ -1090,9 +1091,8 @@ class ProjectUpdateDetail(RetrieveDestroyAPIView):
|
|||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
for unified_job_node in obj.unified_job_nodes.all():
|
for unified_job_node in obj.unified_job_nodes.all():
|
||||||
if unified_job_node.workflow_job.status in ('new', 'pending', 'waiting',
|
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||||
'running', 'updating'):
|
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||||
raise PermissionDenied()
|
|
||||||
return super(ProjectUpdateDetail, self).destroy(request, *args, **kwargs)
|
return super(ProjectUpdateDetail, self).destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
class ProjectUpdateCancel(RetrieveAPIView):
|
class ProjectUpdateCancel(RetrieveAPIView):
|
||||||
@@ -2177,9 +2177,8 @@ class InventoryUpdateDetail(RetrieveDestroyAPIView):
|
|||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
for unified_job_node in obj.unified_job_nodes.all():
|
for unified_job_node in obj.unified_job_nodes.all():
|
||||||
if unified_job_node.workflow_job.status in ('new', 'pending', 'waiting',
|
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||||
'running', 'updating'):
|
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||||
raise PermissionDenied()
|
|
||||||
return super(InventoryUpdateDetail, self).destroy(request, *args, **kwargs)
|
return super(InventoryUpdateDetail, self).destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
class InventoryUpdateCancel(RetrieveAPIView):
|
class InventoryUpdateCancel(RetrieveAPIView):
|
||||||
@@ -2888,9 +2887,8 @@ class JobDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
for unified_job_node in obj.unified_job_nodes.all():
|
for unified_job_node in obj.unified_job_nodes.all():
|
||||||
if unified_job_node.workflow_job.status in ('new', 'pending', 'waiting',
|
if unified_job_node.workflow_job.status in ACTIVE_STATES:
|
||||||
'running', 'updating'):
|
raise PermissionDenied(detail='Can not delete job resource when associated workflow job is running.')
|
||||||
raise PermissionDenied()
|
|
||||||
return super(JobDetail, self).destroy(request, *args, **kwargs)
|
return super(JobDetail, self).destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
class JobLabelList(SubListAPIView):
|
class JobLabelList(SubListAPIView):
|
||||||
|
|||||||
Reference in New Issue
Block a user