<s> from datetime import date <EOL> from celery import task <EOL> from kitsune . customercare . models import Reply <EOL> from kitsune . kbadge . utils import get_or_create_badge <EOL> from kitsune . sumo . decorators import timeit <EOL> @ task ( ) <EOL> @ timeit <EOL> def maybe_award_badge ( badge_template , year , user ) : <EOL> """<STR_LIT>""" <EOL> badge = get_or_create_badge ( badge_template , year ) <EOL> if badge . is_awarded_to ( user ) : <EOL> return <EOL> qs = Reply . objects . filter ( <EOL> user = user , <EOL> created__gte = date ( year , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> created__lt = date ( year + <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> if qs . count ( ) >= <NUM_LIT:50> : <EOL> badge . award_to ( user ) <EOL> return True </s>
