Commit c74e0ddf authored by Okhin's avatar Okhin

Fix of the add_new_url counting as a vote. Also fixed the threshold for...

Fix of the add_new_url counting as a vote. Also fixed the threshold for upvote, and the fact that url was not saved at all
parent 790382db
Pipeline #2594 passed with stages
in 3 minutes
...@@ -157,7 +157,7 @@ class Article(models.Model): ...@@ -157,7 +157,7 @@ class Article(models.Model):
automatically moves the article from _NEW_ to _DRAFT_. automatically moves the article from _NEW_ to _DRAFT_.
""" """
self.score += 1 self.score += 1
if self.score >= ARTICLE_SCORE_THRESHOLD - 1: if self.score >= ARTICLE_SCORE_THRESHOLD:
return 'DRAFT' return 'DRAFT'
else: else:
return self.status return self.status
...@@ -205,6 +205,8 @@ class Article(models.Model): ...@@ -205,6 +205,8 @@ class Article(models.Model):
# the HTTP protocol So, let's get a specific status for that, # the HTTP protocol So, let's get a specific status for that,
# one that can be easily identified. # one that can be easily identified.
article.original_status = 600 article.original_status = 600
article.url = url
article.save() article.save()
return article return article
......
...@@ -28,6 +28,14 @@ class TestArticle(TestCase): ...@@ -28,6 +28,14 @@ class TestArticle(TestCase):
article.recover() article.recover()
assert article.status == 'DRAFT' assert article.status == 'DRAFT'
def test_add_new_url(self):
article = Article.add_new_url(url='https://www.example.org/article')
assert article.status == 'NEW'
assert article.score == 1
article_again = Article.add_new_url(url='https://www.example.org/article')
assert article_again.status == 'NEW'
assert article_again.score == 2
class TestArticleViews(TestCase): class TestArticleViews(TestCase):
def setUp(self): def setUp(self):
......
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