X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/4e4b0b571da8e2156d8174e41ed79c0ecb0c0e7f..854b33110cde1c2bf725f47d9809c23d64577af9:/forum/badges/base.py diff --git a/forum/badges/base.py b/forum/badges/base.py index c3e9fcb..c2dbe30 100644 --- a/forum/badges/base.py +++ b/forum/badges/base.py @@ -5,7 +5,7 @@ from django.contrib.contenttypes.models import ContentType from django.db.models.signals import post_save from forum.models.user import activity_record -from forum.models import Badge, Award, Activity +from forum.models import Badge, Award, Activity, Node import logging @@ -74,6 +74,14 @@ class PostCountableAbstractBadge(CountableAbstractBadge): super(PostCountableAbstractBadge, self).__init__(model, field, expected_value, handler) +class NodeCountableAbstractBadge(CountableAbstractBadge): + def __init__(self, node_type, field, expected_value): + + def handler(instance): + if instance.node_type == node_type: + self.award_badge(instance.author, instance) + + super(NodeCountableAbstractBadge, self).__init__(Node, field, expected_value, handler) class ActivityAbstractBadge(AbstractBadge):