Add ability to distinguish between when comments have zero replies, and when their reply tree wasn't built.

This commit is contained in:
Bryce Boe
2012-02-13 17:24:29 -08:00
committed by Logan Hanks
parent ec4739b452
commit 1e74945a41
3 changed files with 22 additions and 5 deletions

View File

@@ -487,6 +487,11 @@ class FrontController(RedditController):
listing = LinkListing(builder)
pane = listing.listing()
# Indicate that the comment tree wasn't built for comments
for i in pane.things:
if hasattr(i, 'body'):
i.child = None
return pane
def _edit_modcontrib_reddit(self, location, num, after, reverse, count, created):

View File

@@ -708,7 +708,14 @@ class MessageController(ListingController):
if (self.where == 'messages' and
(c.user.pref_threaded_messages or self.message)):
return Listing(self.builder_obj).listing()
return ListingController.listing(self)
pane = ListingController.listing(self)
# Indicate that the comment tree wasn't built for comments
for i in pane.things:
if i.was_comment:
i.child = None
return pane
def query(self):
if self.where == 'messages':

View File

@@ -186,10 +186,15 @@ def replace_render(listing, item, render_func):
style = style or c.render_style or 'html'
replacements = {}
child_txt = ( hasattr(item, "child") and item.child )\
and item.child.render(style = style) or ""
replacements["childlisting"] = child_txt
if hasattr(item, 'child'):
if item.child:
replacements['childlisting'] = item.child.render(style=style)
else:
# Special case for when the comment tree wasn't built which
# occurs both in the inbox and spam page view of comments.
replacements['childlisting'] = None
else:
replacements['childlisting'] = ''
#only LinkListing has a show_nums attribute
if listing: