]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/project_badges/badges.py
Changing the global socket timeout is evil
[osqa.git] / forum_modules / project_badges / badges.py
1 from django.utils.translation import ugettext as _
2 from forum.badges.base import AbstractBadge
3 from forum.models import Badge, Tag
4 from forum.actions import VoteUpAction
5 import settings
6
7 class BugBuster(AbstractBadge):
8     type = Badge.SILVER
9     name = _("Bug Buster")
10     description = _('Got %s upvotes in a question tagged with "bug"') % settings.BUG_BUSTER_VOTES_UP
11     listen_to = (VoteUpAction, )
12
13     def award_to(self, action):
14         if action.node.node_type == "question" and int(action.node.score) == int(settings.BUG_BUSTER_VOTES_UP):
15             try:
16                 bug = Tag.objects.get(name="bug")
17                 if bug in action.node.tags.all():
18                     return action.node.author
19             except Exception:
20                 pass