From bc804b150c417d5ac1d2b24390304fdeb7427a4c Mon Sep 17 00:00:00 2001 From: hernani Date: Sat, 8 May 2010 21:40:41 +0000 Subject: [PATCH] Make sure an action is a real action before using is as the trigger of a badge. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@184 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/badges/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/forum/badges/base.py b/forum/badges/base.py index 728f8b5..3af46f7 100644 --- a/forum/badges/base.py +++ b/forum/badges/base.py @@ -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 -- 2.39.5