def award_to(self, awardee=None, email=None, awarder=None,
                 description='', raise_already_awarded=False):
        # If no awarder given, assume this is on the badge creator's behalf.
        if not awarder:
            awarder = self.creator

        if not self.allows_award_to(awarder):
            raise BadgeAwardNotAllowedException()

        # If we have an email, but no awardee, try looking up the user.
        if email and not awardee:
            qs = User.objects.filter(email=email)
            if not qs:
                # If there's no user for this email address, create a
                # DeferredAward for future claiming.

                if self.unique and DeferredAward.objects.filter(
                    badge=self, email=email).exists():
                    raise BadgeAlreadyAwardedException()

                da = DeferredAward(badge=self, email=email)
                da.save()
                return da

            # Otherwise, we'll use the most recently created user
            awardee = qs.latest('date_joined')

        if self.unique and self.is_awarded_to(awardee):
            if raise_already_awarded:
                raise BadgeAlreadyAwardedException()
            else:
                return Award.objects.filter(user=awardee, badge=self)[0]

        return Award.objects.create(user=awardee, badge=self,
                                    creator=awarder,
                                    description=description)
Award this badge to the awardee on the awarder's behalf
dataset/ETHPy150Open mozilla/django-badger/badger/models.py/Badge.award_to