]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/node.py
Fixes question and answer count in the sidebar.
[osqa.git] / forum / models / node.py
index 75b39339e3284d74e913f60d99e80fa35a7b8d21..a8c674c3b0787db6209225e76b107afe6f4048ad 100644 (file)
@@ -106,6 +106,9 @@ class NodeQuerySet(CachedQuerySet):
         apply_bool = lambda q, b: b and q or ~q
         return self.filter(*[apply_bool(models.Q(state_string__contains="(%s)" % s), b) for s, b in kwargs.items()])
 
+    def children_count(self, child_type):
+        return NodeMetaClass.types[child_type].objects.filter_state(deleted=False).filter(parent__in=self).count()
+
 
 class NodeManager(CachedManager):
     use_for_related_fields = True