Commit 6b7d1e64 authored by Michal Čihař's avatar Michal Čihař

Store positive/negative vote directly

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8eef9585
......@@ -155,11 +155,12 @@ class Suggestion(models.Model):
'''
Adds (or updates) vote for a suggestion.
'''
vote, dummy = Vote.objects.get_or_create(
vote, created = Vote.objects.get_or_create(
suggestion=self,
user=request.user
user=request.user,
defaults={'positive': positive}
)
if vote.positive != positive:
if not created or vote.positive != positive:
vote.positive = positive
vote.save()
......
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