]> git.openstreetmap.org Git - osqa.git/commitdiff
Fix error reported at http://meta.osqa.net/question/1660/just-been-awarded-student...
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 7 May 2010 21:03:21 +0000 (21:03 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 7 May 2010 21:03:21 +0000 (21:03 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@164 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/user.py
forum/badges/base.py

index b281f1495672b2eadcb95a5681f52106690ed386..dcbb27ba39d8ba27e63e91022d2a55c5517f28c0 100644 (file)
@@ -39,10 +39,12 @@ class AwardAction(ActionProxy):
         award.delete()\r
 \r
     @classmethod\r
-    def get_for(cls, user, node, badge):\r
+    def get_for(cls, user, badge, node=False):\r
         try:\r
-            award = Award.objects.get(user=user, node=node, badge=badge)\r
-            return award.action\r
+            if node is False:\r
+                return Award.objects.get(user=user, badge=badge).action\r
+            else:\r
+                return Award.objects.get(user=user, node=node, badge=badge).action\r
         except:\r
             return None\r
 \r
index fce6b6e30301c542a585f76ba8e2bd799eabb9fc..728f8b52433d52cf72619f1c41de690fba9ce4e5 100644 (file)
@@ -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