From dbfc77cdf18bf52c3d35da5b8170d16753fe3a3a Mon Sep 17 00:00:00 2001 From: hernani Date: Fri, 7 May 2010 21:03:21 +0000 Subject: [PATCH] Fix error reported at http://meta.osqa.net/question/1660/just-been-awarded-student-badge-twice git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@164 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/actions/user.py | 8 +++++--- forum/badges/base.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/forum/actions/user.py b/forum/actions/user.py index b281f14..dcbb27b 100644 --- a/forum/actions/user.py +++ b/forum/actions/user.py @@ -39,10 +39,12 @@ class AwardAction(ActionProxy): award.delete() @classmethod - def get_for(cls, user, node, badge): + def get_for(cls, user, badge, node=False): try: - award = Award.objects.get(user=user, node=node, badge=badge) - return award.action + if node is False: + return Award.objects.get(user=user, badge=badge).action + else: + return Award.objects.get(user=user, node=node, badge=badge).action except: return None diff --git a/forum/badges/base.py b/forum/badges/base.py index fce6b6e..728f8b5 100644 --- a/forum/badges/base.py +++ b/forum/badges/base.py @@ -60,10 +60,10 @@ class AbstractBadge(object): def award(cls, user, action, once=False): if once: node = None + awarded = AwardAction.get_for(user, cls.ondb) else: node = action.node - - awarded = AwardAction.get_for(user, node, cls.ondb) + awarded = AwardAction.get_for(user, cls.ondb, node) 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 -- 2.39.5