Add dyn:comments_count

This commit is contained in:
Gregory Soutade
2014-06-05 19:56:47 +02:00
parent 193b439517
commit 361be87cb2
4 changed files with 39 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ class Index(DynastieGenerator):
'replace' : self.createReplace,
'first_page_only' : self.createFirstPageOnly,
'ljdc_last' : self.createLJDCLast,
'comments_count' : self.createCommentsCount,
}
self.first_try = True
@@ -77,6 +78,14 @@ class Index(DynastieGenerator):
root.replaceChild(div_element, replace_elem)
return div_element
def createCommentsCount(self, posts, dom, root, node):
from dynastie.models import Comment
if self.cur_post_obj is None:
count = 0
else:
count = Comment.objects.filter(post=self.cur_post_obj.id).count()
self.replaceByText(dom, root, node, str(count))
def createNavigation(self, posts, dom, root, node):
if self.nb_pages == 0 or self.nb_pages == 1:
return None