Skip to content
Snippets Groups Projects
Commit 77456ae6 authored by ml bonhomme's avatar ml bonhomme :bee:
Browse files

fix schema issue + have text orientation in bulk endpoint too

parent f3a88531
No related branches found
No related tags found
No related merge requests found
......@@ -219,7 +219,7 @@ class TranscriptionSerializer(serializers.ModelSerializer):
read_only=True,
help_text='This field is deprecated; please use the `confidence` field instead.',
)
orientation = EnumField(TextOrientation)
orientation = EnumField(TextOrientation, required=False)
class Meta:
model = Transcription
......@@ -328,6 +328,7 @@ class SimpleTranscriptionSerializer(serializers.Serializer):
max_value=1,
required=False,
)
orientation = EnumField(TextOrientation, required=False)
def validate(self, data):
if not ('score' in data) ^ ('confidence' in data):
......@@ -399,6 +400,7 @@ class TranscriptionBulkItemSerializer(serializers.Serializer):
help_text='This field is deprecated; please use the `confidence` field instead.'
)
confidence = serializers.FloatField(min_value=0, max_value=1, required=False)
orientation = EnumField(TextOrientation, required=False)
def validate(self, data):
# Element retrieval and checks is done in the BulkSerializer to avoid duplicate queries
......
......@@ -23,7 +23,7 @@ class SolrDocumentSerializer(serializers.Serializer):
transcription_id = serializers.UUIDField(allow_null=True)
transcription_text = serializers.CharField(allow_null=True)
transcription_confidence = serializers.FloatField(min_value=0, max_value=1, required=False)
transcription_orientation = EnumField(TextOrientation, allow_null=True)
transcription_orientation = EnumField(TextOrientation, required=False)
transcription_worker = serializers.CharField(allow_null=True)
classification_id = serializers.UUIDField(allow_null=True)
......
......@@ -354,7 +354,7 @@ class TestBulkElementTranscriptions(FixtureAPITestCase):
second_elt = created_elts.get(transcriptions__text='stock')
first_tr = Transcription.objects.get(text="stuck")
second_tr = Transcription.objects.get(text="stock")
thrid_td = Transcription.objects.get(text="stack")
third_td = Transcription.objects.get(text="stack")
self.assertListEqual(response.json(), [{
'id': str(first_tr.id),
'element_id': str(first_elt.id),
......@@ -364,7 +364,7 @@ class TestBulkElementTranscriptions(FixtureAPITestCase):
'element_id': str(second_elt.id),
'created': True
}, {
'id': str(thrid_td.id),
'id': str(third_td.id),
'element_id': str(self.line.id),
'created': False
}])
......
......@@ -94,18 +94,21 @@ class TestBulkTranscriptions(FixtureAPITestCase):
"id": str(first_tr),
"element_id": str(element1.id),
"text": "Sneasel",
"orientation": "horizontal-lr",
"confidence": 0.54,
},
{
"id": str(third_tr),
"element_id": str(element2.id),
"text": "Charizard",
"orientation": "horizontal-lr",
"confidence": 0.85,
},
{
"id": str(second_tr),
"element_id": str(element1.id),
"text": "Raticate",
"orientation": "horizontal-lr",
"confidence": 0.12,
},
]
......
......@@ -247,6 +247,7 @@ SPECTACULAR_SETTINGS = {
'ClassificationState': 'arkindex.documents.models.ClassificationState',
'PonosState': 'ponos.models.State',
'WorkerVersionState': 'arkindex.dataimport.models.WorkerVersionState',
'TextOrientation': 'arkindex.documents.models.TextOrientation',
},
'TAGS': [
{'name': 'classifications'},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment