From 20ef84dc749b719a3b62564021797df51bf5875e Mon Sep 17 00:00:00 2001 From: Valentin Rigal <rigal@teklia.com> Date: Wed, 3 Jul 2024 07:58:12 +0000 Subject: [PATCH] Remove TranscriptionEntity.worker_version_id field from the API --- arkindex/documents/serializers/entities.py | 6 +-- arkindex/documents/tests/test_entities_api.py | 45 ------------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/arkindex/documents/serializers/entities.py b/arkindex/documents/serializers/entities.py index 7adcdce7d9..c205e80310 100644 --- a/arkindex/documents/serializers/entities.py +++ b/arkindex/documents/serializers/entities.py @@ -9,7 +9,7 @@ from rest_framework.exceptions import ValidationError from arkindex.documents.models import Corpus, Entity, EntityType, TranscriptionEntity from arkindex.documents.serializers.light import CorpusLightSerializer, EntityTypeLightSerializer from arkindex.documents.serializers.ml import WorkerRunSummarySerializer -from arkindex.project.serializer_fields import ForbiddenField, WorkerRunIDField +from arkindex.project.serializer_fields import WorkerRunIDField from arkindex.project.validators import ForbiddenValidator @@ -221,7 +221,6 @@ class TranscriptionEntityCreateSerializer(serializers.ModelSerializer): """ offset = serializers.IntegerField(min_value=0) length = serializers.IntegerField(min_value=1) - worker_version_id = ForbiddenField() worker_run_id = WorkerRunIDField( required=False, write_only=True, @@ -245,7 +244,6 @@ class TranscriptionEntityCreateSerializer(serializers.ModelSerializer): "entity", "offset", "length", - "worker_version_id", "worker_run_id", "worker_run", "confidence", @@ -294,12 +292,10 @@ class TranscriptionEntityCreateSerializer(serializers.ModelSerializer): return data -@extend_schema_serializer(deprecate_fields=("worker_version_id", )) class TranscriptionEntitySerializer(TranscriptionEntityCreateSerializer): """ Serialize the link between a transcription and a detailed entity """ - worker_version_id = serializers.UUIDField(read_only=True) entity = BaseEntitySerializer() diff --git a/arkindex/documents/tests/test_entities_api.py b/arkindex/documents/tests/test_entities_api.py index a949b6e74d..f0481fcd9a 100644 --- a/arkindex/documents/tests/test_entities_api.py +++ b/arkindex/documents/tests/test_entities_api.py @@ -590,24 +590,6 @@ class TestEntitiesAPI(FixtureAPITestCase): ) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) - def test_create_transcription_entity_worker_version(self): - self.client.force_login(self.user) - with self.assertNumQueries(4): - response = self.client.post( - reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - data={ - "entity": str(self.entity.id), - "offset": 4, - "length": len(self.entity.name), - "worker_version_id": str(self.worker_version_1.id), - }, - format="json", - ) - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - self.assertDictEqual(response.json(), { - "worker_version_id": ["This field is forbidden."], - }) - def test_create_transcription_entity_worker_run(self): """ A regular user can create classifications with a WorkerRun of their own local process @@ -636,24 +618,6 @@ class TestEntitiesAPI(FixtureAPITestCase): "confidence": None, }) - def test_create_transcription_entity_forbidden_version(self): - self.client.force_login(self.user) - with self.assertNumQueries(4): - response = self.client.post( - reverse("api:transcription-entity-create", kwargs={"pk": str(self.transcription.id)}), - data={ - "entity": str(self.entity.id), - "offset": 4, - "length": 8, - "worker_version_id": str(self.worker_version_1.id), - }, - format="json", - ) - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - self.assertDictEqual(response.json(), { - "worker_version_id": ["This field is forbidden."], - }) - def test_create_transcription_entity_bad_worker_run(self): self.client.force_login(self.user) with self.assertNumQueries(5): @@ -1074,7 +1038,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": self.transcriptionentity.length, "offset": self.transcriptionentity.offset, - "worker_version_id": str(self.worker_version_1.id), "worker_run": None, "confidence": None }] @@ -1105,7 +1068,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": self.transcriptionentity.length, "offset": self.transcriptionentity.offset, - "worker_version_id": str(self.worker_version_1.id), "worker_run": None, "confidence": None }], @@ -1228,7 +1190,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": None, "confidence": None }] @@ -1268,7 +1229,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": { "id": str(self.worker_run_2.id), "summary": self.worker_run_2.summary, @@ -1309,7 +1269,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 2, - "worker_version_id": None, "worker_run": None, "confidence": None }] @@ -1348,7 +1307,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": None, "confidence": None }] @@ -1397,7 +1355,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": { "id": str(self.worker_run_2.id), "summary": self.worker_run_2.summary, @@ -1444,7 +1401,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 13, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": None, "confidence": None }] @@ -1493,7 +1449,6 @@ class TestEntitiesAPI(FixtureAPITestCase): }, "length": 8, "offset": 8, - "worker_version_id": str(self.worker_version_2.id), "worker_run": None, "confidence": None }] -- GitLab