From 5d387e5b91c7f7e48796ce0860be7feab031dd2c Mon Sep 17 00:00:00 2001
From: ml bonhomme <bonhomme@teklia.com>
Date: Wed, 10 Jul 2024 10:55:15 +0000
Subject: [PATCH] remove worker_version from TranscriptionBulkSerializer

---
 arkindex/documents/serializers/ml.py          |  5 ++--
 .../tests/test_bulk_transcriptions.py         | 27 ++-----------------
 .../tests/test_create_transcriptions.py       |  2 +-
 3 files changed, 5 insertions(+), 29 deletions(-)

diff --git a/arkindex/documents/serializers/ml.py b/arkindex/documents/serializers/ml.py
index dcfab609b3..bd82333d30 100644
--- a/arkindex/documents/serializers/ml.py
+++ b/arkindex/documents/serializers/ml.py
@@ -18,7 +18,7 @@ from arkindex.documents.models import (
     Transcription,
 )
 from arkindex.documents.serializers.light import ElementZoneSerializer
-from arkindex.project.serializer_fields import EnumField, ForbiddenField, LinearRingField, WorkerRunIDField
+from arkindex.project.serializer_fields import EnumField, LinearRingField, WorkerRunIDField
 from arkindex.project.tools import polygon_outside_image
 from arkindex.project.validators import ConditionalUniqueValidator
 
@@ -297,7 +297,7 @@ class TranscriptionCreateSerializer(serializers.ModelSerializer):
 
     class Meta:
         model = Transcription
-        fields = ("text", "worker_version", "worker_run_id", "confidence", "orientation")
+        fields = ("text", "worker_run_id", "confidence", "orientation")
 
     def validate(self, data):
         data = super().validate(data)
@@ -427,7 +427,6 @@ class TranscriptionBulkItemSerializer(serializers.Serializer):
 
 
 class TranscriptionBulkSerializer(serializers.Serializer):
-    worker_version = ForbiddenField()
     worker_run_id = WorkerRunIDField(
         help_text=dedent("""
             A WorkerRun ID that the new transcriptions will refer to.
diff --git a/arkindex/documents/tests/test_bulk_transcriptions.py b/arkindex/documents/tests/test_bulk_transcriptions.py
index 8c84c55a09..b94712e375 100644
--- a/arkindex/documents/tests/test_bulk_transcriptions.py
+++ b/arkindex/documents/tests/test_bulk_transcriptions.py
@@ -64,7 +64,7 @@ class TestBulkTranscriptions(FixtureAPITestCase):
 
     def test_bulk_transcriptions_required_worker_run(self):
         """
-        A worker run must be set, worker version field is forbidden.
+        A worker run must be set
         """
         self.client.force_login(self.superuser)
 
@@ -75,7 +75,6 @@ class TestBulkTranscriptions(FixtureAPITestCase):
 
         with self.assertNumQueries(2):
             response = self.client.post(reverse("api:transcription-bulk"), {
-                "worker_version": str(self.worker_version.id),
                 "transcriptions": [
                     {
                         "element_id": str(element1.id),
@@ -91,8 +90,7 @@ class TestBulkTranscriptions(FixtureAPITestCase):
             }, format="json")
             self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
         self.assertDictEqual(response.json(), {
-            "worker_run_id": ["This field is required."],
-            "worker_version": ["This field is forbidden."],
+            "worker_run_id": ["This field is required."]
         })
 
     def test_bulk_transcriptions_requires_confidence(self):
@@ -199,27 +197,6 @@ class TestBulkTranscriptions(FixtureAPITestCase):
             ]
         })
 
-    def test_bulk_transcriptions_worker_run_and_version(self):
-        self.client.force_login(self.user)
-        test_element = self.corpus.elements.get(name="Volume 2, page 1r")
-        with self.assertNumQueries(3):
-            response = self.client.post(reverse("api:transcription-bulk"), {
-                "worker_version": str(self.worker_version.id),
-                "worker_run_id": str(self.local_worker_run.id),
-                "transcriptions": [
-                    {
-                        "element_id": str(test_element.id),
-                        "text": "The Glow Cloud does not need to converse with us.",
-                        "orientation": TextOrientation.VerticalRightToLeft.value,
-                        "confidence": 0.33
-                    },
-                ],
-            }, format="json")
-            self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
-        self.assertDictEqual(response.json(), {
-            "worker_version": ["This field is forbidden."],
-        })
-
     def test_worker_run_non_local(self):
         """
         A regular user cannot create transcriptions with a WorkerRun of a non-local process
diff --git a/arkindex/documents/tests/test_create_transcriptions.py b/arkindex/documents/tests/test_create_transcriptions.py
index 74f26fe4c9..1800ed9d2b 100644
--- a/arkindex/documents/tests/test_create_transcriptions.py
+++ b/arkindex/documents/tests/test_create_transcriptions.py
@@ -169,7 +169,7 @@ class TestTranscriptionCreate(FixtureAPITestCase):
 
     def test_worker_version_ignored(self):
         self.client.force_login(self.user)
-        with self.assertNumQueries(5):
+        with self.assertNumQueries(4):
             response = self.client.post(
                 reverse("api:transcription-create", kwargs={"pk": self.line.id}),
                 format="json",
-- 
GitLab