]> git.openstreetmap.org Git - osqa.git/commitdiff
Put the badge count denormalization back.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 15 May 2010 23:10:41 +0000 (23:10 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 15 May 2010 23:10:41 +0000 (23:10 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@287 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/user.py

index aef541a1bb02abe2744b8572099f3e03c3e366cc..19dfa5efb0b25d9a070edc8e05d27aee0e432802 100644 (file)
@@ -1,7 +1,7 @@
 from django.utils.translation import ugettext as _
 from django.db.models import F
 from forum.models.action import ActionProxy
-from forum.models import Award
+from forum.models import Award, Badge
 from forum import settings
 from forum.settings import APP_SHORT_NAME
 
@@ -58,6 +58,16 @@ class AwardAction(ActionProxy):
         award.save()
         award.badge.awarded_count = F('awarded_count') + 1
         award.badge.save()
+
+        if award.badge.type == Badge.GOLD:
+            self.user.gold += 1
+        if award.badge.type == Badge.SILVER:
+            self.user.silver += 1
+        if award.badge.type == Badge.BRONZE:
+            self.user.silver += 1
+
+        self.user.save()
+
         self.user.message_set.create(message=_("""Congratulations, you have received a badge '%(badge_name)s'. Check out <a href=\"%(profile_url)s\">your profile</a>.""") %
                                      dict(badge_name=award.badge.name, profile_url=self.user.get_profile_url()))