mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 14:09:28 -02:30
Emit approve/deny status for websockets, update doc string + a comment
This commit is contained in:
@@ -249,4 +249,3 @@ class InstanceGroupTowerPermission(ModelAccessPermission):
|
|||||||
if request.method == 'DELETE' and obj.name == "tower":
|
if request.method == 'DELETE' and obj.name == "tower":
|
||||||
return False
|
return False
|
||||||
return super(InstanceGroupTowerPermission, self).has_object_permission(request, view, obj)
|
return super(InstanceGroupTowerPermission, self).has_object_permission(request, view, obj)
|
||||||
|
|
||||||
|
|||||||
@@ -4487,8 +4487,7 @@ class WorkflowApprovalDeny(RetrieveAPIView):
|
|||||||
obj.deny(request)
|
obj.deny(request)
|
||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
# Placeholder code for approval notification support
|
||||||
|
|
||||||
class WorkflowApprovalNotificationsList(SubListAPIView):
|
class WorkflowApprovalNotificationsList(SubListAPIView):
|
||||||
|
|
||||||
model = models.Notification
|
model = models.Notification
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ def check_user_access_with_errors(user, model_class, action, *args, **kwargs):
|
|||||||
access_instance = access_class(user, save_messages=True)
|
access_instance = access_class(user, save_messages=True)
|
||||||
access_method = getattr(access_instance, 'can_%s' % action, None)
|
access_method = getattr(access_instance, 'can_%s' % action, None)
|
||||||
result = access_method(*args, **kwargs)
|
result = access_method(*args, **kwargs)
|
||||||
logger.debug('%s.%s %r returned %r', access_instance.__class__.__name__,
|
logger.error('%s.%s %r returned %r', access_instance.__class__.__name__,
|
||||||
access_method.__name__, args, result)
|
access_method.__name__, args, result)
|
||||||
return (result, access_instance.messages)
|
return (result, access_instance.messages)
|
||||||
|
|
||||||
@@ -2824,13 +2824,18 @@ class WorkflowApprovalTemplateAccess(BaseAccess):
|
|||||||
|
|
||||||
@check_superuser
|
@check_superuser
|
||||||
def can_add(self, data):
|
def can_add(self, data):
|
||||||
|
'''
|
||||||
|
A user can create an approval template if they are a superuser, an org admin
|
||||||
|
of the org connected to the workflow, or if they are assigned as admins to
|
||||||
|
the workflow.
|
||||||
|
'''
|
||||||
if data is None: # Hide direct creation in API browser
|
if data is None: # Hide direct creation in API browser
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return (self.check_related('workflow_approval_template', UnifiedJobTemplate, role_field='admin_role'))
|
return (self.check_related('workflow_approval_template', UnifiedJobTemplate, role_field='admin_role'))
|
||||||
|
|
||||||
def can_start(self, obj, validate_license=False):
|
def can_start(self, obj, validate_license=False):
|
||||||
# Super users can start any job
|
# for copying WFJTs that contain approval nodes
|
||||||
if self.user.is_superuser:
|
if self.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -684,6 +684,7 @@ class WorkflowApproval(UnifiedJob):
|
|||||||
from awx.main.signals import model_serializer_mapping # circular import
|
from awx.main.signals import model_serializer_mapping # circular import
|
||||||
self.status = 'successful'
|
self.status = 'successful'
|
||||||
self.save()
|
self.save()
|
||||||
|
self.websocket_emit_status(self.status)
|
||||||
changes = model_to_dict(self, model_serializer_mapping())
|
changes = model_to_dict(self, model_serializer_mapping())
|
||||||
changes['status'] = ['pending', 'successful']
|
changes['status'] = ['pending', 'successful']
|
||||||
activity_entry = ActivityStream(
|
activity_entry = ActivityStream(
|
||||||
@@ -701,6 +702,7 @@ class WorkflowApproval(UnifiedJob):
|
|||||||
from awx.main.signals import model_serializer_mapping # circular import
|
from awx.main.signals import model_serializer_mapping # circular import
|
||||||
self.status = 'failed'
|
self.status = 'failed'
|
||||||
self.save()
|
self.save()
|
||||||
|
self.websocket_emit_status(self.status)
|
||||||
changes = model_to_dict(self, model_serializer_mapping())
|
changes = model_to_dict(self, model_serializer_mapping())
|
||||||
changes['status'] = ['pending', 'failed']
|
changes['status'] = ['pending', 'failed']
|
||||||
activity_entry = ActivityStream(
|
activity_entry = ActivityStream(
|
||||||
|
|||||||
Reference in New Issue
Block a user