X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/dbfc77cdf18bf52c3d35da5b8170d16753fe3a3a..b8f3a2323d03384198863e35d6467a8624a2e31a:/forum/models/meta.py diff --git a/forum/models/meta.py b/forum/models/meta.py index 6465105..53d4c49 100644 --- a/forum/models/meta.py +++ b/forum/models/meta.py @@ -64,7 +64,15 @@ class Badge(models.Model): @models.permalink def get_absolute_url(self): - return ('badge', [], {'id': self.id, 'slug': slugify(self.name)}) + return ('badge', [], {'id': self.id, 'slug': slugify(self.name)}) + + def save(self, *args, **kwargs): + if isinstance(self.awarded_count, models.expressions.ExpressionNode): + super(Badge, self).save(*args, **kwargs) + self.awarded_count = self.__class__.objects.filter(id=self.id).values_list('awarded_count', flat=True)[0] + else: + super(Badge, self).save(*args, **kwargs) + class Meta: app_label = 'forum'