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
75fb3fe6
Commit
75fb3fe6
authored
Apr 23, 2017
by
luxcem
Browse files
fix score for up / down
parent
5db4c8b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/models/vote.py
View file @
75fb3fe6
...
...
@@ -68,7 +68,9 @@ class UnDVotedMixin(models.Model):
self
.
und_score_up
+=
diff_score
# Update self score, use update and filter to avoid triggering signals
self
.
__class__
.
objects
.
filter
(
id
=
self
.
id
).
update
(
und_score
=
F
(
"und_score"
)
+
diff_score
)
und_score
=
F
(
"und_score"
)
+
diff_score
,
und_score_up
=
F
(
"und_score_up"
)
+
diff_score
)
def
downvote
(
self
,
username
):
diff_score
=
0
...
...
@@ -93,7 +95,9 @@ class UnDVotedMixin(models.Model):
self
.
und_score_down
+=
diff_score
# Update self score, use update and filter to avoid triggering signals
self
.
__class__
.
objects
.
filter
(
id
=
self
.
id
).
update
(
und_score
=
F
(
"und_score"
)
+
diff_score
)
und_score
=
F
(
"und_score"
)
+
diff_score
,
und_score_down
=
F
(
"und_score_down"
)
+
diff_score
)
def
update_und_score
(
self
):
"""Reset score to the correct count (should not be necessary)"""
...
...
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