mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Addressing comments, updating tests, etc.
This commit is contained in:
@@ -198,8 +198,8 @@ class TaskPermission(ModelAccessPermission):
|
||||
|
||||
class WorkflowApprovalPermission(ModelAccessPermission):
|
||||
'''
|
||||
Permission check used by workflow approval and deny views
|
||||
to determine who can has access to approve and deny paused workflow nodes
|
||||
Permission check used by workflow `approval` and `deny` views to determine
|
||||
who has access to approve and deny paused workflow nodes
|
||||
'''
|
||||
|
||||
def check_post_permissions(self, request, view, obj=None):
|
||||
|
||||
@@ -3473,15 +3473,6 @@ class WorkflowApprovalTemplateSerializer(UnifiedJobTemplateSerializer):
|
||||
return res
|
||||
|
||||
|
||||
class WorkflowJobTemplateApprovalSerializer(UnifiedJobTemplateSerializer):
|
||||
class Meta:
|
||||
model = WorkflowApprovalTemplate
|
||||
fields = ('*',)
|
||||
|
||||
def post(self, obj):
|
||||
return # POST only!!!
|
||||
|
||||
|
||||
class LaunchConfigurationBaseSerializer(BaseSerializer):
|
||||
scm_branch = serializers.CharField(allow_blank=True, allow_null=True, required=False, default=None)
|
||||
job_type = serializers.ChoiceField(allow_blank=True, allow_null=True, required=False, default=None,
|
||||
|
||||
@@ -4473,7 +4473,7 @@ class WorkflowApprovalApprove(RetrieveAPIView):
|
||||
if not request.user.can_access(models.WorkflowApproval, 'approve_or_deny', obj):
|
||||
raise PermissionDenied(detail=_("User does not have permission to approve or deny this workflow."))
|
||||
if obj.status != 'pending':
|
||||
return Response("This workflow step has already been approved or denied.", status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({"error": _("This workflow step has already been approved or denied.")}, status=status.HTTP_400_BAD_REQUEST)
|
||||
obj.approve(request)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
@@ -4488,6 +4488,6 @@ class WorkflowApprovalDeny(RetrieveAPIView):
|
||||
if not request.user.can_access(models.WorkflowApproval, 'approve_or_deny', obj):
|
||||
raise PermissionDenied(detail=_("User does not have permission to approve or deny this workflow."))
|
||||
if obj.status != 'pending':
|
||||
return Response("This workflow step has already been approved or denied.", status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({"error": _("This workflow step has already been approved or denied.")}, status=status.HTTP_400_BAD_REQUEST)
|
||||
obj.deny(request)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
Reference in New Issue
Block a user