Commit 6ad22830 authored by Okhin's avatar Okhin
Browse files

Fixing the create function

parent a7309f8a
Pipeline #2559 passed with stages
in 2 minutes and 59 seconds
......@@ -36,6 +36,7 @@ class ArticleSerializer(serializers.ModelSerializer):
fields = ('id', 'url', 'title', 'tags', 'extracts', 'status',
'und_score_up', 'und_score_down')
def create(self, **validated_data):
def create(self, validated_data):
article = Article.add_new_url(**validated_data)
return article
......@@ -172,14 +172,14 @@ class Article(VoteMixin):
super(Article, self).downvote(by)
def add_new_url(url, by=None, **data):
def add_new_url(by=None, **data):
""" Manually add a new article from its URL.
Verify if the article has not been submitted before and automatically
upvote for the given user if applicable.
import requests
url = cleanup_url(url)
url = cleanup_url(data.pop('url', None))
article, created = Article.objects.get_or_create(url=url,
Supports Markdown
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