]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/tag.py
Serve up robots.txt as plain text.
[osqa.git] / forum / models / tag.py
index 791636fa0a9810f2dee4c935d8bc5304d64d9bf0..eca23e468ae8d186605b5989831191284a8fed77 100644 (file)
@@ -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))