From c7635321891f6d69e2f75d1a3013ec2c0ad7686e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Lesage?= <tlesage@teklia.com> Date: Wed, 24 Apr 2024 17:51:37 +0200 Subject: [PATCH] Proper validation for task restart based on Task.original_task --- arkindex/ponos/api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arkindex/ponos/api.py b/arkindex/ponos/api.py index e4b60bc1c1..a6ba542a10 100644 --- a/arkindex/ponos/api.py +++ b/arkindex/ponos/api.py @@ -224,10 +224,8 @@ class TaskRestart(ProcessACLMixin, CreateAPIView): detail="Task's state must be in a final state to be restarted." ) # TODO Check the original_task_id field directly once it is implemented - # https://gitlab.teklia.com/arkindex/frontend/-/issues/1383 - _, *suffix = task.slug.rsplit("_old", 1) - if suffix: + if len(Task.objects.filter(original_task=task)) > 0: raise ValidationError( detail="This task has already been restarted" ) -- GitLab