From c123654f6daea6bc0aab586d130f25c10a7d71d3 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 16 May 2023 03:30:55 +0300 Subject: [PATCH] actually fix roulette (i forgot that i had @lazy before def has_badge) --- files/helpers/casino.py | 3 +-- files/helpers/useractions.py | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/helpers/casino.py b/files/helpers/casino.py index a929f1d3e..5f994ec69 100644 --- a/files/helpers/casino.py +++ b/files/helpers/casino.py @@ -106,5 +106,4 @@ def distribute_wager_badges(user, wager, won): badges_earned.add(159) for badge in badges_earned: - try: badge_grant(user, badge) - except: continue + badge_grant(user, badge) diff --git a/files/helpers/useractions.py b/files/helpers/useractions.py index 54b2c705a..d65229b76 100644 --- a/files/helpers/useractions.py +++ b/files/helpers/useractions.py @@ -6,8 +6,9 @@ from files.helpers.alerts import send_repeatable_notification def badge_grant(user, badge_id, description=None, url=None, notify=True, check_if_exists=True): assert user != None - if check_if_exists and user.has_badge(badge_id): - return + if check_if_exists: + existing = g.db.query(Badge).filter_by(user_id=user.id, badge_id=badge_id).one_or_none() + if existing: return if description and len(description) > 256: abort(400, "Custom description is too long, max 256 characters!")