From 790382dba1903ffcb84ab6ecf0fb8a4afed865c6 Mon Sep 17 00:00:00 2001 From: Okhin Date: Tue, 14 May 2019 16:39:11 +0200 Subject: [PATCH] Add_new_url now also generates a vote on article creation --- apps/rp/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/rp/models.py b/apps/rp/models.py index efdad3d..e62fd38 100644 --- a/apps/rp/models.py +++ b/apps/rp/models.py @@ -187,11 +187,12 @@ class Article(models.Model): (article, created) = Article.objects.get_or_create(url=url, defaults=data) - # If the article was already there, we should upvote it - if not created: - if article.status == "REJECTED": - return None - article.upvote() + # Always upvote the article, except if it was rejected before. + # It's either a new one, and adding it count as a vote, or it existed + # already, and this is a vote. + if article.status == "REJECTED": + return None + article.upvote() # Let's add the tags if tags: -- GitLab