aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorrr-2016-06-06 21:05:43 +0200
committerrr-2016-06-08 22:38:35 +0200
commit053d1889e08dd07a68e033f5c95986daaab6dd33 (patch)
tree21d0ed50908c04da5f09087eceaf59493f0a68e1 /server
parentb28f689077719b450f67d9f127b9aeec8e30d6bb (diff)
server/scores: voting for <1 removes favorite
Diffstat (limited to 'server')
-rw-r--r--server/szurubooru/func/scores.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/szurubooru/func/scores.py b/server/szurubooru/func/scores.py
index 5ed3960..646f1f4 100644
--- a/server/szurubooru/func/scores.py
+++ b/server/szurubooru/func/scores.py
@@ -1,5 +1,6 @@
import datetime
from szurubooru import db, errors
+from szurubooru.func import favorites
class InvalidScoreTargetError(errors.ValidationError): pass
class InvalidScoreValueError(errors.ValidationError): pass
@@ -32,6 +33,10 @@ def get_score(entity, user):
def set_score(entity, user, score):
if not score:
delete_score(entity, user)
+ try:
+ favorites.unset_favorite(entity, user)
+ except favorites.InvalidFavoriteTargetError:
+ pass
return
if score not in (-1, 1):
raise InvalidScoreValueError(
@@ -39,6 +44,11 @@ def set_score(entity, user, score):
score_entity = _get_score_entity(entity, user)
if score_entity:
score_entity.score = score
+ if score < 1:
+ try:
+ favorites.unset_favorite(entity, user)
+ except favorites.InvalidFavoriteTargetError:
+ pass
else:
table, get_column = _get_table_info(entity)
score_entity = table()

© 2015 - 2026 Jakob L. Kreuze