- {'dif_days': str(settings.NECROMANCER_DIF_DAYS), 'up_votes': str(settings.NECROMANCER_UP_VOTES)}
-
- def __init__(self):
- def handler(instance):
- if instance.node_type == "answer" and instance.added_at >= (instance.question.added_at + timedelta(days=int(settings.NECROMANCER_DIF_DAYS))):
- self.award_badge(instance.author, instance)
-
- super(NecromancerBadge, self).__init__(Node, "vote_up_count", settings.NECROMANCER_UP_VOTES, handler)
-
-
-class TaxonomistBadge(AbstractBadge):
- type = const.SILVER_BADGE
- description = _('Created a tag used by %s questions') % str(settings.TAXONOMIST_USE_COUNT)
-
- def __init__(self):
- def handler(instance, **kwargs):
- if instance.used_count == settings.TAXONOMIST_USE_COUNT:
- self.award_badge(instance.created_by, instance)
-
- post_save.connect(handler, sender=Tag, weak=False)
-
-
-#class GeneralistTag(AbstractBadge):
-# pass
-
-#class ExpertTag(AbstractBadge):
-# pass
-
-#class YearlingTag(AbstractBadge):
-# pass
-
-
-
+ {'dif_days': settings.NECROMANCER_DIF_DAYS, 'up_votes': settings.NECROMANCER_UP_VOTES}
+
+ def award_to(self, action):
+ if (action.node.node_type == "answer") and (
+ action.node.added_at >= (action.node.question.added_at + timedelta(days=int(settings.NECROMANCER_DIF_DAYS)))
+ ) and (int(action.node.score) == int(settings.NECROMANCER_UP_VOTES)):
+ return action.node.author
+
+class Taxonomist(AbstractBadge):
+ type = Badge.SILVER
+ listen_to = tuple()
+ name = _("Taxonomist")
+ description = _('Created a tag used by %s questions') % settings.TAXONOMIST_USE_COUNT
+
+ def award_to(self, action):
+ return None
+
+class ValidatedEmail(AbstractBadge):
+ type = Badge.BRONZE
+ listen_to = (EmailValidationAction,)
+ name = _("Validated Email")
+ description = _("User who has validated email associated to the account")
+ award_once = True
+
+ def award_to(self, action):
+ return action.user
\ No newline at end of file