Remove comment ID references for deleted comments.

This commit is contained in:
Jason Harvey
2013-10-08 12:42:37 -07:00
parent 53a24a9849
commit 2f0fa46e89
7 changed files with 66 additions and 42 deletions

View File

@@ -3723,8 +3723,13 @@ class UserText(CachedTemplate):
if text is None:
text = ''
fullname = ''
# Only pass fullname on things that are not deleted
if not getattr(item, 'deleted', False) and hasattr(item, '_fullname'):
fullname = item._fullname
CachedTemplate.__init__(self,
fullname = item._fullname if item else "",
fullname = fullname,
text = text,
have_form = have_form,
editable = editable,

View File

@@ -197,7 +197,8 @@ class _CommentBuilder(Builder):
if parent:
if not hasattr(parent, 'child'):
parent.child = empty_listing()
parent.child.parent_name = parent._fullname
if not parent.deleted:
parent.child.parent_name = parent._fullname
parent.child.things.append(cm)
else:
final.append(cm)
@@ -221,7 +222,8 @@ class _CommentBuilder(Builder):
raise KeyError("%r not in cids but it wasn't ignored" % p_id)
parent.child = empty_listing(morelink)
parent.child.parent_name = parent._fullname
if not parent.deleted:
parent.child.parent_name = parent._fullname
if not self.load_more:
return final
@@ -264,7 +266,8 @@ class _CommentBuilder(Builder):
parent.child.things.append(w_mc2)
else:
parent.child = empty_listing(w_mc2)
parent.child.parent_name = parent._fullname
if not parent.deleted:
parent.child.parent_name = parent._fullname
#add more children
if cid_tree.has_key(to_add):

View File

@@ -1014,11 +1014,17 @@ class Comment(Thing, Printable):
if not hasattr(item, 'target'):
item.target = "_top" if cname else None
if item.parent_id:
if item.parent_id in cids:
item.parent_permalink = '#' + utils.to36(item.parent_id)
else:
if item.parent_id in parents:
parent = parents[item.parent_id]
item.parent_permalink = parent.make_permalink(item.link, item.subreddit)
else:
parent = cids[item.parent_id]
if not parent.deleted:
if item.parent_id in cids:
item.parent_permalink = '#' + utils.to36(item.parent_id)
else:
item.parent_permalink = parent.make_permalink(item.link, item.subreddit)
else:
item.parent_permalink = None
else:
item.parent_permalink = None
@@ -1045,6 +1051,8 @@ class Comment(Thing, Printable):
item.author != user and
not item.show_spam)))
item.have_form = not item.deleted
extra_css = ''
if item.deleted:
extra_css += "grayed"
@@ -1127,7 +1135,8 @@ class Comment(Thing, Printable):
editable=item.is_author,
nofollow=item.nofollow,
target=item.target,
extra_css=extra_css)
extra_css=extra_css,
have_form=item.have_form)
item.lastedited = CachedVariable("lastedited")

View File

@@ -47,7 +47,9 @@ ${parent.midcol(not thing.collapsed, cls = cls)}
<%def name="ParentDiv()">
${parent.ParentDiv()}
<a name="${thing._id36}" ></a>
%if not thing.deleted:
<a name="${thing._id36}"></a>
%endif
%if c.profilepage:
%if thing.link:
%if thing.link.title:

View File

@@ -54,7 +54,14 @@ ${self.RenderPrintable()}
%endif
</%def>
<%def name="thing_css_class(what)">thing id-${what._fullname}</%def>
<%def name="thing_css_class(what)">
<%
cssclass = "thing"
if not getattr(what, 'deleted', False):
cssclass += " id-" + what._fullname
%>
${cssclass}
</%def>
<%def name="thing_css_rowclass(what)">
<%
@@ -83,7 +90,9 @@ ${self.RenderPrintable()}
</%def>
<%def name="thing_data_attributes(what)">
data-fullname="${what._fullname}"
% if not getattr(what, 'deleted', False):
data-fullname="${what._fullname}"
% endif
% if hasattr(what, 'campaign'):
data-cid="${what.campaign}"
% endif

View File

@@ -255,38 +255,32 @@
</%def>
<%def name="commentbuttons()">
<li class="first">
${self.bylink_button(_("permalink"), thing.permalink)}
</li>
%if thing.saved:
<li class="comment-unsave-button">
${self.state_button("unsave", _("unsave"), "toggle_save(this)", _("save"))}
</li>
%else:
<li class="comment-save-button">
${self.state_button("save", _("save"), "toggle_save(this)", _("unsave"))}
</li>
%endif
%if c.profilepage:
<li>
${self.bylink_button(_("context"), thing.permalink + "?context=3")}
</li>
%if not thing.deleted:
<li class="first">
${self.comment_button("comment",
_("full comments") + " (%d)" % thing.full_comment_count,
thing.full_comment_path,
_sr_path = True,
a_class = None,
newwindow = thing.new_window)}
${self.bylink_button(_("permalink"), thing.permalink)}
</li>
%endif
%if thing.deleted:
%if thing.parent_permalink and not thing.profilepage:
<li>
${self.bylink_button(_("parent"), thing.parent_permalink)}
%if thing.saved:
<li class="comment-unsave-button">
${self.state_button("unsave", _("unsave"), "toggle_save(this)", _("save"))}
</li>
%else:
<li class="comment-save-button">
${self.state_button("save", _("save"), "toggle_save(this)", _("unsave"))}
</li>
%endif
%if c.profilepage:
<li>
${self.bylink_button(_("context"), thing.permalink + "?context=3")}
</li>
<li class="first">
${self.comment_button("comment",
_("full comments") + " (%d)" % thing.full_comment_count,
thing.full_comment_path,
_sr_path = True,
a_class = None,
newwindow = thing.new_window)}
</li>
%endif
%else:
%if not thing.profilepage:
%if thing.parent_permalink:
<li>

View File

@@ -116,8 +116,10 @@
<div class="${thing.css_class}">
%endif
##this is set for both editting selftext and creating new comments
<input type="hidden" name="thing_id" value="${thing.fullname or ''}"/>
%if thing.fullname:
##this is set for both editting selftext and creating new comments
<input type="hidden" name="thing_id" value="${thing.fullname}"/>
%endif
%if not thing.creating:
<div class="usertext-body">