X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/e945778bce1d0af9091f7be2503b06756298b905..bdc1f3f4e02e0d558bb80e70679d5e56172d32b9:/forum_modules/default_badges/badges.py diff --git a/forum_modules/default_badges/badges.py b/forum_modules/default_badges/badges.py index 2305dd4..e84fcbf 100644 --- a/forum_modules/default_badges/badges.py +++ b/forum_modules/default_badges/badges.py @@ -42,10 +42,6 @@ class NodeScoreBadge(AbstractBadge): abstract = True listen_to = (VoteAction,) - @property - def description(self): - return _('Answer voted up %s times') % str(self.expected_score) - def award_to(self, action): if (action.node.node_type == self.node_type) and (action.node.score == int(self.expected_score)): return action.node.author @@ -55,6 +51,10 @@ class QuestionScoreBadge(NodeScoreBadge): abstract = True node_type = "question" + @property + def description(self): + return _('Question voted up %s times') % str(self.expected_score) + class NiceQuestion(QuestionScoreBadge): expected_score = settings.NICE_QUESTION_VOTES_UP name = _("Nice Question") @@ -74,6 +74,10 @@ class AnswerScoreBadge(NodeScoreBadge): abstract = True node_type = "answer" + @property + def description(self): + return _('Answer voted up %s times') % str(self.expected_score) + class NiceAnswer(AnswerScoreBadge): expected_score = settings.NICE_ANSWER_VOTES_UP name = _("Nice Answer") @@ -108,6 +112,7 @@ class FavoriteQuestion(FavoriteQuestionBadge): expected_count = settings.FAVORITE_QUESTION_FAVS class StellarQuestion(FavoriteQuestionBadge): + type = Badge.GOLD name = _("Stellar Question") expected_count = settings.STELLAR_QUESTION_FAVS @@ -221,7 +226,7 @@ class Pundit(AbstractBadge): description = _('Left %s comments') % settings.PUNDIT_COMMENT_COUNT def award_to(self, action): - if (action.user.nodes.filter(node_type="comment", deleted=None)) == int(settings.CIVIC_DUTY_VOTES): + if action.user.nodes.filter_state(deleted=False).filter(node_type="comment").count() == int(settings.CIVIC_DUTY_VOTES): return action.user @@ -237,6 +242,7 @@ class SelfLearner(AbstractBadge): class StrunkAndWhite(AbstractBadge): + type = Badge.SILVER award_once = True listen_to = (ReviseAction,) name = _("Strunk & White") @@ -254,7 +260,7 @@ class Student(AbstractBadge): description = _('Asked first question with at least one up vote') def award_to(self, action): - if (action.node.node_type == "question") and (action.node.author.nodes.filter(node_type="question", deleted=None, score=1).count() == 1): + if (action.node.node_type == "question") and (action.node.author.nodes.filter_state(deleted=False).filter(node_type="question", score=1).count() == 1): return action.node.author @@ -265,7 +271,7 @@ class Teacher(AbstractBadge): description = _('Answered first question with at least one up vote') def award_to(self, action): - if (action.node.node_type == "answer") and (action.node.author.nodes.filter(node_type="answer", deleted=None, score=1).count() == 1): + if (action.node.node_type == "answer") and (action.node.author.nodes.filter_state(deleted=False).filter(node_type="answer", score=1).count() == 1): return action.node.author