@task()
@timeit
def maybe_award_badge(badge_template, year, user):
 badge = get_or_create_badge(badge_template, year)
 if badge.is_awarded_to(user):
  return
 from kitsune.questions.models import Answer
 qs = Answer.objects.filter(creator=user, created__gte=date(year, 1, 1), created__lt=date((year + 1), 1, 1))
 if (qs.count() >= 30):
  badge.award_to(user)
  return True

@ task ( ) @ timeit def maybe_award_badge ( badge_template , year , user ) : badge = get_or_create_badge ( badge_template , year ) if badge . is_awarded_to ( user ) : return from kitsune . questions . models import Answer qs = Answer . objects . filter ( creator = user , created__gte = date ( year , 1 , 1 ) , created__lt = date ( ( year + 1 ) , 1 , 1 ) ) if ( qs . count ( ) >= 30 ) : badge . award_to ( user ) return True
award the specific badge to the user if theyve earned it .