]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/meta.py
Fix error reported at http://meta.osqa.net/question/1673/default-values-on-badges...
[osqa.git] / forum / models / meta.py
index 6465105d3d1f4d272b30583fc9c9cc7e0590c50c..53d4c493049697efd25192185b25ef8611f2a751 100644 (file)
@@ -64,7 +64,15 @@ class Badge(models.Model):
 \r
     @models.permalink\r
     def get_absolute_url(self):\r
-        return ('badge', [], {'id': self.id, 'slug': slugify(self.name)})        \r
+        return ('badge', [], {'id': self.id, 'slug': slugify(self.name)})\r
+\r
+    def save(self, *args, **kwargs):\r
+        if isinstance(self.awarded_count, models.expressions.ExpressionNode):\r
+            super(Badge, self).save(*args, **kwargs)\r
+            self.awarded_count = self.__class__.objects.filter(id=self.id).values_list('awarded_count', flat=True)[0]\r
+        else:\r
+            super(Badge, self).save(*args, **kwargs)\r
+\r
 \r
     class Meta:\r
         app_label = 'forum'\r