do not try awarding disabled badges to users

This commit is contained in:
Frédéric Péters 2014-06-12 15:09:58 +02:00
parent c418142386
commit dcb35a97cb
1 changed files with 5 additions and 2 deletions

View File

@ -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: