X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/981f2713a5caa510f596a089f78579f5ed317bd5..dca62877790867febcd047d0bf7a3ac431ff9c84:/forum/models/tag.py diff --git a/forum/models/tag.py b/forum/models/tag.py index 791636f..eca23e4 100644 --- a/forum/models/tag.py +++ b/forum/models/tag.py @@ -11,8 +11,8 @@ from forum import modules class ActiveTagManager(CachedManager): use_for_related_fields = True - def get_query_set(self): - return super(ActiveTagManager, self).get_query_set().exclude(used_count__lt=1) + def get_queryset(self): + return super(ActiveTagManager, self).get_queryset().exclude(used_count__lt=1) class Tag(BaseModel): name = models.CharField(max_length=255, unique=True) @@ -32,12 +32,10 @@ class Tag(BaseModel): return force_unicode(self.name) def add_to_usage_count(self, value): - if int(self.used_count + value) < 0: + if self.used_count + value < 0: self.used_count = 0 else: - self.used_count += value - - self.save() + self.used_count = models.F('used_count') + value def cache_key(self): return self._generate_cache_key(Tag.safe_cache_name(self.name))