]> git.openstreetmap.org Git - osqa.git/commitdiff
Make sure an action is a real action before using is as the trigger of a badge.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 8 May 2010 21:40:41 +0000 (21:40 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 8 May 2010 21:40:41 +0000 (21:40 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@184 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/badges/base.py

index 728f8b52433d52cf72619f1c41de690fba9ce4e5..3af46f7c20496c0ac101e9af9658343f0528f571 100644 (file)
@@ -4,7 +4,7 @@ from string import lower
 from django.contrib.contenttypes.models import ContentType
 from django.db.models.signals import post_save
 
-from forum.models import Badge, Node
+from forum.models import Badge, Node, Action
 from forum.actions import AwardAction
 
 import logging
@@ -65,5 +65,7 @@ class AbstractBadge(object):
             node = action.node
             awarded = AwardAction.get_for(user, cls.ondb, node)
 
+        trigger = isinstance(action, Action) and action or None
+
         if not awarded:
-            AwardAction(user=user, node=node, ip=action.ip).save(data=dict(badge=cls.ondb, trigger=action))
\ No newline at end of file
+            AwardAction(user=user, node=node, ip=action.ip).save(data=dict(badge=cls.ondb, trigger=trigger))
\ No newline at end of file