Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
6ea3bba4
Unverified
Commit
6ea3bba4
authored
4 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Re-serialize a full transcription in TranscriptionCreate API view
parent
b8fccc8b
No related branches found
No related tags found
1 merge request
!775
Re-serialize a full transcription in TranscriptionCreate API view
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/api/ml.py
+7
-3
7 additions, 3 deletions
arkindex/documents/api/ml.py
arkindex/documents/tests/test_transcription_create.py
+16
-0
16 additions, 0 deletions
arkindex/documents/tests/test_transcription_create.py
with
23 additions
and
3 deletions
arkindex/documents/api/ml.py
+
7
−
3
View file @
6ea3bba4
...
...
@@ -14,8 +14,8 @@ from arkindex_common.ml_tool import MLToolType
from
arkindex_common.enums
import
EntityType
from
arkindex.documents.serializers.ml
import
(
ClassificationsSerializer
,
ClassificationCreateSerializer
,
ClassificationSerializer
,
TranscriptionsSerializer
,
Transcription
Create
Serializer
,
DataSourceSt
at
s
Serializer
,
ClassificationsSelectionSerializer
,
ClassificationMode
,
TranscriptionsSerializer
,
TranscriptionSerializer
,
TranscriptionCre
at
e
Serializer
,
DataSourceStatsSerializer
,
ClassificationsSelectionSerializer
,
ClassificationMode
,
CountMLClassSerializer
,
MLClassSerializer
)
from
arkindex.documents.pagexml
import
PageXmlParser
...
...
@@ -86,7 +86,11 @@ class TranscriptionCreate(CreateAPIView):
serializer
.
is_valid
(
raise_exception
=
True
)
obj
=
self
.
perform_create
(
serializer
)
headers
=
self
.
get_success_headers
(
serializer
.
data
)
return
Response
({
'
id
'
:
obj
.
id
},
status
=
status
.
HTTP_201_CREATED
,
headers
=
headers
)
return
Response
(
# Use a single transcription serializer for the response
TranscriptionSerializer
(
obj
).
data
,
status
=
status
.
HTTP_201_CREATED
,
headers
=
headers
)
class
TranscriptionBulk
(
CreateAPIView
,
UpdateAPIView
):
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_transcription_create.py
+
16
−
0
View file @
6ea3bba4
...
...
@@ -102,6 +102,22 @@ class TestTranscriptionCreate(FixtureAPITestCase):
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
tr
=
Transcription
.
objects
.
get
(
text
=
'
A perfect day in a perfect place
'
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
id
'
:
str
(
tr
.
id
),
'
score
'
:
None
,
'
source
'
:
{
'
id
'
:
str
(
tr
.
source
.
id
),
'
internal
'
:
False
,
'
name
'
:
''
,
'
revision
'
:
''
,
'
slug
'
:
'
manual
'
,
'
type
'
:
'
recognizer
'
},
'
text
'
:
'
A perfect day in a perfect place
'
,
'
type
'
:
'
line
'
,
'
zone
'
:
None
})
new_ts
=
Transcription
.
objects
.
get
(
text
=
'
A perfect day in a perfect place
'
,
type
=
TranscriptionType
.
Line
)
self
.
assertIsNone
(
new_ts
.
zone
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment