From: hernani Date: Sat, 15 May 2010 23:10:41 +0000 (+0000) Subject: Put the badge count denormalization back. X-Git-Tag: live~844 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/3fcef4ec7d2509284a43a2325ae2341d5553ab35 Put the badge count denormalization back. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@287 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/actions/user.py b/forum/actions/user.py index aef541a..19dfa5e 100644 --- a/forum/actions/user.py +++ b/forum/actions/user.py @@ -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 your profile.""") % dict(badge_name=award.badge.name, profile_url=self.user.get_profile_url()))