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
9c28a82e
Commit
9c28a82e
authored
2 years ago
by
Yoann Schneider
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove internal user restriction on TranscriptionEntity creation
parent
d205bbea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1708
Remove internal user restriction on TranscriptionEntity creation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/serializers/entities.py
+0
-6
0 additions, 6 deletions
arkindex/documents/serializers/entities.py
arkindex/documents/tests/test_entities_api.py
+17
-12
17 additions, 12 deletions
arkindex/documents/tests/test_entities_api.py
with
17 additions
and
18 deletions
arkindex/documents/serializers/entities.py
+
0
−
6
View file @
9c28a82e
...
...
@@ -263,12 +263,6 @@ class TranscriptionEntitySerializer(serializers.ModelSerializer):
if
not
data
[
'
transcription
'
]:
errors
[
'
transcription
'
]
=
[
'
invalid UUID or Corpus write-access is forbidden
'
]
user
=
self
.
context
[
'
request
'
].
user
if
data
.
get
(
'
worker_version
'
)
and
not
(
user
.
is_authenticated
and
user
.
is_internal
):
errors
[
'
worker_version_id
'
]
=
[
'
An internal user is required to link an entity to a transcription with a worker version.
'
]
worker_run
=
data
.
get
(
'
worker_run
'
)
if
worker_run
is
not
None
:
data
[
'
worker_version
'
]
=
WorkerVersion
(
id
=
worker_run
.
version_id
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_entities_api.py
+
17
−
12
View file @
9c28a82e
...
...
@@ -499,8 +499,8 @@ 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
.
internal_
user
)
with
self
.
assertNumQueries
(
1
0
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
1
2
):
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-entity-create
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
transcription
.
id
)}),
data
=
self
.
tr_entities_version_sample
,
...
...
@@ -515,17 +515,22 @@ class TestEntitiesAPI(FixtureAPITestCase):
)
self
.
assertEqual
(
transcription_entity
.
worker_version
,
self
.
worker_version_1
)
def
test_create_transcription_entity_worker_version_requires_internal
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-entity-create
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
transcription
.
id
)}),
data
=
self
.
tr_entities_version_sample
,
format
=
'
json
'
def
test_create_transcription_entity_worker_version_internal_user
(
self
):
self
.
client
.
force_login
(
self
.
internal_user
)
with
self
.
assertNumQueries
(
10
):
response
=
self
.
client
.
post
(
reverse
(
'
api:transcription-entity-create
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
transcription
.
id
)}),
data
=
self
.
tr_entities_version_sample
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
transcription_entity
=
TranscriptionEntity
.
objects
.
get
(
transcription
=
self
.
transcription
,
entity
=
self
.
entity
,
offset
=
self
.
tr_entities_sample
[
'
offset
'
],
length
=
self
.
tr_entities_sample
[
'
length
'
]
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertDictEqual
(
response
.
json
(),
{
"
worker_version_id
"
:
[
'
An internal user is required to link an entity to a transcription with a worker version.
'
]
})
self
.
assertEqual
(
transcription_entity
.
worker_version
,
self
.
worker_version_1
)
def
test_create_transcription_entity_worker_run
(
self
):
self
.
client
.
force_login
(
self
.
user
)
...
...
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