From dcb35a97cb15df7ceb79007d913e891886e5ac38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 12 Jun 2014 15:09:58 +0200 Subject: [PATCH] do not try awarding disabled badges to users --- askbot/models/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 05153b2b..76dc438b 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -3252,6 +3252,11 @@ def record_award_event(instance, created, **kwargs): We also recaculate awarded_count of this badge and user information. """ if created: + try: + badge = get_badge(instance.badge.slug) + except KeyError: + return + #todo: change this to community user who gives the award activity = Activity( user=instance.user, @@ -3265,8 +3270,6 @@ def record_award_event(instance, created, **kwargs): instance.badge.awarded_count += 1 instance.badge.save() - badge = get_badge(instance.badge.slug) - if badge.level == const.GOLD_BADGE: instance.user.gold += 1 if badge.level == const.SILVER_BADGE: