Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
6c1c776d
Commit
6c1c776d
authored
May 14, 2019
by
Okhin
Browse files
set and unset priority were working, but now the serializer displays the field
parent
ccb166de
Changes
2
Hide whitespace changes
Inline
Side-by-side
apps/rp/api/serializers.py
View file @
6c1c776d
...
...
@@ -23,7 +23,8 @@ class ArticleSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Article
fields
=
(
'id'
,
'url'
,
'title'
,
'tags'
,
'extracts'
,
'status'
,
'score'
)
fields
=
(
'id'
,
'url'
,
'title'
,
'tags'
,
'extracts'
,
'status'
,
'score'
,
'priority'
)
def
create
(
self
,
validated_data
):
article
=
Article
.
add_new_url
(
**
validated_data
)
...
...
apps/rp/tests/test_article.py
View file @
6c1c776d
...
...
@@ -194,3 +194,23 @@ class TestArticleApi(TestCase):
a
=
ArticleFactory
(
status
=
'PUBLISHED'
)
r
=
self
.
client
.
post
(
'/api/articles/{}/recover/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
403
def
test_api_set_priority
(
self
):
self
.
user
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'can_change_priority'
))
self
.
client
.
force_login
(
user
=
self
.
user
)
a
=
ArticleFactory
(
status
=
'DRAFT'
)
assert
a
.
priority
is
False
r
=
self
.
client
.
post
(
'/api/articles/{}/set_priority/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
200
assert
r
.
data
[
'priority'
]
def
test_api_unset_priority
(
self
):
self
.
user
.
user_permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'can_change_priority'
))
self
.
client
.
force_login
(
user
=
self
.
user
)
a
=
ArticleFactory
(
status
=
'DRAFT'
,
priority
=
True
)
assert
a
.
priority
r
=
self
.
client
.
post
(
'/api/articles/{}/unset_priority/'
.
format
(
a
.
id
))
assert
r
.
status_code
==
200
assert
r
.
data
[
'priority'
]
is
False
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment