perf: Admin and auditor can view and stop task

This commit is contained in:
wangruidong
2024-11-08 17:50:33 +08:00
committed by Bryan
parent 1a41a7450e
commit 5b27acf4ef
11 changed files with 75 additions and 29 deletions

View File

@@ -225,7 +225,11 @@ class JobExecutionViewSet(OrgBulkModelViewSet):
return Response({'error': serializer.errors}, status=400)
task_id = serializer.validated_data['task_id']
try:
instance = get_object_or_404(JobExecution, pk=task_id, creator=request.user)
user = request.user
if user.has_perm("audits.view_joblog"):
instance = get_object_or_404(JobExecution, pk=task_id)
else:
instance = get_object_or_404(JobExecution, pk=task_id, creator=request.user)
except Http404:
return Response(
{'error': _('The task is being created and cannot be interrupted. Please try again later.')},