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
eb673df2
Commit
eb673df2
authored
4 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Add IsVerified permission on Validate/RejectClassification endpoints
parent
f798bfe6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1162
Add IsVerified permission on Validate/RejectClassification endpoints
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/api/ml.py
+1
-0
1 addition, 0 deletions
arkindex/documents/api/ml.py
arkindex/documents/tests/test_moderation.py
+27
-4
27 additions, 4 deletions
arkindex/documents/tests/test_moderation.py
with
28 additions
and
4 deletions
arkindex/documents/api/ml.py
+
1
−
0
View file @
eb673df2
...
...
@@ -478,6 +478,7 @@ class ManageClassificationsSelection(SelectionMixin, CorpusACLMixin, CreateAPIVi
class
ClassificationModerationActionsMixin
(
GenericAPIView
):
permission_classes
=
(
IsVerified
,
)
serializer_class
=
ClassificationSerializer
def
get_queryset
(
self
):
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_moderation.py
+
27
−
4
View file @
eb673df2
...
...
@@ -260,14 +260,27 @@ class TestClasses(FixtureAPITestCase):
classification
.
refresh_from_db
()
self
.
assertEqual
(
classification
.
moderator
,
self
.
user
)
def
test_classification_validate_
without_permissions
(
self
):
def
test_classification_validate_
requires_login
(
self
):
classification
=
self
.
element
.
classifications
.
create
(
ml_class
=
self
.
text
,
confidence
=
.
5
,
)
with
self
.
assertNumQueries
(
0
):
response
=
self
.
client
.
put
(
reverse
(
'
api:classification-validate
'
,
kwargs
=
{
'
pk
'
:
classification
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_classification_validate_requires_verified
(
self
):
self
.
user
.
verified_email
=
False
self
.
user
.
save
()
self
.
client
.
force_login
(
self
.
user
)
classification
=
self
.
element
.
classifications
.
create
(
ml_class
=
self
.
text
,
confidence
=
.
5
,
)
with
self
.
assertNumQueries
(
2
):
response
=
self
.
client
.
put
(
reverse
(
'
api:classification-validate
'
,
kwargs
=
{
'
pk
'
:
classification
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_worker_classification_reject
(
self
):
self
.
client
.
force_login
(
self
.
user
)
...
...
@@ -311,11 +324,21 @@ class TestClasses(FixtureAPITestCase):
with
self
.
assertRaises
(
Classification
.
DoesNotExist
):
classification
.
refresh_from_db
()
def
test_classification_reject_
without_permissions
(
self
):
def
test_classification_reject_
requires_login
(
self
):
classification
=
self
.
element
.
classifications
.
create
(
ml_class
=
self
.
text
,
confidence
=
.
42
)
with
self
.
assertNumQueries
(
0
):
response
=
self
.
client
.
put
(
reverse
(
'
api:classification-reject
'
,
kwargs
=
{
'
pk
'
:
classification
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_classification_reject_requires_verified
(
self
):
self
.
user
.
verified_email
=
False
self
.
user
.
save
()
self
.
client
.
force_login
(
self
.
user
)
classification
=
self
.
element
.
classifications
.
create
(
ml_class
=
self
.
text
,
confidence
=
.
42
)
with
self
.
assertNumQueries
(
2
):
response
=
self
.
client
.
put
(
reverse
(
'
api:classification-reject
'
,
kwargs
=
{
'
pk
'
:
classification
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_classification_can_still_be_moderated
(
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