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
790382db
Commit
790382db
authored
May 14, 2019
by
Okhin
Browse files
Add_new_url now also generates a vote on article creation
parent
37e81ba1
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/models.py
View file @
790382db
...
@@ -187,11 +187,12 @@ class Article(models.Model):
...
@@ -187,11 +187,12 @@ class Article(models.Model):
(
article
,
created
)
=
Article
.
objects
.
get_or_create
(
url
=
url
,
(
article
,
created
)
=
Article
.
objects
.
get_or_create
(
url
=
url
,
defaults
=
data
)
defaults
=
data
)
# If the article was already there, we should upvote it
# Always upvote the article, except if it was rejected before.
if
not
created
:
# It's either a new one, and adding it count as a vote, or it existed
if
article
.
status
==
"REJECTED"
:
# already, and this is a vote.
return
None
if
article
.
status
==
"REJECTED"
:
article
.
upvote
()
return
None
article
.
upvote
()
# Let's add the tags
# Let's add the tags
if
tags
:
if
tags
:
...
...
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