def has_badge(self, badge_id):
        """Returns whether this user has earned the given badge."""
        if badge_id:
            return CompletedChallenge.objects.filter(profile=self, challenge__pk=badge_id,
                                                date_badge_earned__isnull=False).count() == 1
        else:
            return False