]> git.openstreetmap.org Git - osqa.git/commitdiff
Fixes question and answer count in the sidebar.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 10 Jul 2010 01:26:49 +0000 (01:26 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 10 Jul 2010 01:26:49 +0000 (01:26 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@516 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/node.py
forum/skins/default/templates/question_list/count.html
forum/views/readers.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
index cf347ed16a09929f9af342f9c8af016f4852084f..dbb45eb8ed70af83747eb4c6a598c68dc016cb27 100644 (file)
@@ -1,15 +1,18 @@
-{% load i18n %}\r
-{% load humanize %}\r
+{% spaceless %}\r
+{% load i18n humanize extra_tags %}\r
+{% declare %}\r
+    answer_count = questions.children_count('answer')\r
+{% enddeclare %}\r
 \r
 <div class="boxC">\r
     <div class="questions-count">\r
-        {{ questions_count }}<span style="color:black;font-size:14px;margin-left:5px">{{ list_description }}</span>\r
+        {{ questions.paginator.count }}<span style="color:black;font-size:14px;margin-left:5px">{{ list_description }}</span>\r
     </div>\r
 \r
 \r
     {% if answer_count %}\r
     <div class="questions-count">\r
-        {{ answer_count }}<span style="color:black;font-size:14px;margin-left:5px">{{ answer_description }}</span>\r
+        {{ answer_count }}<span style="color:black;font-size:14px;margin-left:5px">{% trans "answers" %}</span>\r
     </div>\r
 \r
     {% endif %}\r
@@ -19,4 +22,5 @@
             {{ questions.paginator.sort_description }}\r
         </p>\r
     </div>\r
-</div>
\ No newline at end of file
+</div>\r
+{% endspaceless %}
\ No newline at end of file
index 40bd16cfd7ddb272bf7b0da07d6a456b32b1349f..a47d42cd5b4e97ef34a71a38428daff13240f937 100644 (file)
@@ -165,10 +165,8 @@ def question_list(request, initial,
     return pagination.paginated(request, ('questions', paginator_context or QuestionListPaginatorContext()), {
     "questions" : questions,
     "questions_count" : questions.count(),
-    "answer_count" : answer_count,
     "keywords" : keywords,
     "list_description": list_description,
-    "answer_description": answer_description,
     "base_path" : base_path,
     "page_title" : page_title,
     "tab" : "questions",