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: