Commit 6c1c776d authored by okhin's avatar okhin 🚴

set and unset priority were working, but now the serializer displays the field

parent ccb166de
......@@ -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)
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment