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
a167b02c
Commit
a167b02c
authored
4 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make worker_version required
parent
ff94b4d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/serializers/ml.py
+4
-2
4 additions, 2 deletions
arkindex/documents/serializers/ml.py
arkindex/documents/tests/test_bulk_transcriptions.py
+10
-2
10 additions, 2 deletions
arkindex/documents/tests/test_bulk_transcriptions.py
with
14 additions
and
4 deletions
arkindex/documents/serializers/ml.py
+
4
−
2
View file @
a167b02c
...
...
@@ -380,7 +380,7 @@ class TranscriptionBulkItemSerializer(serializers.Serializer):
class
TranscriptionBulkSerializer
(
serializers
.
Serializer
):
worker_version
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
WorkerVersion
.
objects
.
all
()
,
default
=
None
)
worker_version
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
WorkerVersion
.
objects
.
all
())
transcriptions
=
TranscriptionBulkItemSerializer
(
many
=
True
)
def
validate
(
self
,
data
):
...
...
@@ -414,7 +414,9 @@ class TranscriptionBulkSerializer(serializers.Serializer):
for
transcription
in
validated_data
[
'
transcriptions
'
]
]
Transcription
.
objects
.
bulk_create
(
transcriptions
)
return
{
"
transcriptions
"
:
transcriptions
}
validated_data
[
'
transcriptions
'
]
=
transcriptions
return
validated_data
class
ClassificationBulkSerializer
(
serializers
.
Serializer
):
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_bulk_transcriptions.py
+
10
−
2
View file @
a167b02c
...
...
@@ -2,10 +2,16 @@ from django.urls import reverse
from
rest_framework
import
status
from
arkindex_common.enums
import
TranscriptionType
from
arkindex.project.tests
import
FixtureAPITestCase
from
arkindex.dataimport.models
import
WorkerVersion
class
TestBulkTranscriptions
(
FixtureAPITestCase
):
@classmethod
def
setUpTestData
(
cls
):
super
().
setUpTestData
()
cls
.
worker_version
=
WorkerVersion
.
objects
.
get
(
worker__slug
=
'
reco
'
)
def
test_bulk_transcriptions_requires_login
(
self
):
with
self
.
assertNumQueries
(
0
):
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-bulk
'
))
...
...
@@ -15,8 +21,9 @@ class TestBulkTranscriptions(FixtureAPITestCase):
self
.
client
.
force_login
(
self
.
user
)
self
.
user
.
corpus_right
.
all
().
delete
()
forbidden_element
=
self
.
corpus
.
elements
.
get
(
name
=
'
Volume 1, page 1r
'
)
with
self
.
assertNumQueries
(
3
):
with
self
.
assertNumQueries
(
4
):
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-bulk
'
),
{
"
worker_version
"
:
str
(
self
.
worker_version
.
id
),
"
transcriptions
"
:
[
{
"
element_id
"
:
str
(
forbidden_element
.
id
),
...
...
@@ -48,8 +55,9 @@ class TestBulkTranscriptions(FixtureAPITestCase):
self
.
assertFalse
(
element1
.
transcriptions
.
exists
())
self
.
assertFalse
(
element2
.
transcriptions
.
exists
())
with
self
.
assertNumQueries
(
4
):
with
self
.
assertNumQueries
(
5
):
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-bulk
'
),
{
"
worker_version
"
:
str
(
self
.
worker_version
.
id
),
"
transcriptions
"
:
[
{
"
element_id
"
:
str
(
element1
.
id
),
...
...
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