diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 04f7c8b80..b2e873674 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -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, diff --git a/r2/r2/models/_builder.pyx b/r2/r2/models/_builder.pyx index ef174fea5..79a76cb7a 100644 --- a/r2/r2/models/_builder.pyx +++ b/r2/r2/models/_builder.pyx @@ -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): diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index b65ad2cce..7d11ceee1 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -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") diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index ab1c80f5c..2d7680e08 100755 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -47,7 +47,9 @@ ${parent.midcol(not thing.collapsed, cls = cls)} <%def name="ParentDiv()"> ${parent.ParentDiv()} - + %if not thing.deleted: + + %endif %if c.profilepage: %if thing.link: %if thing.link.title: diff --git a/r2/r2/templates/printable.html b/r2/r2/templates/printable.html index 280f2cb0c..8268a158a 100644 --- a/r2/r2/templates/printable.html +++ b/r2/r2/templates/printable.html @@ -54,7 +54,14 @@ ${self.RenderPrintable()} %endif -<%def name="thing_css_class(what)">thing id-${what._fullname} +<%def name="thing_css_class(what)"> + <% + cssclass = "thing" + if not getattr(what, 'deleted', False): + cssclass += " id-" + what._fullname + %> + ${cssclass} + <%def name="thing_css_rowclass(what)"> <% @@ -83,7 +90,9 @@ ${self.RenderPrintable()} <%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 diff --git a/r2/r2/templates/printablebuttons.html b/r2/r2/templates/printablebuttons.html index c83360577..aa4a91574 100644 --- a/r2/r2/templates/printablebuttons.html +++ b/r2/r2/templates/printablebuttons.html @@ -255,38 +255,32 @@ <%def name="commentbuttons()"> -
  • - ${self.bylink_button(_("permalink"), thing.permalink)} -
  • - %if thing.saved: -
  • - ${self.state_button("unsave", _("unsave"), "toggle_save(this)", _("save"))} -
  • - %else: -
  • - ${self.state_button("save", _("save"), "toggle_save(this)", _("unsave"))} -
  • - %endif - %if c.profilepage: -
  • - ${self.bylink_button(_("context"), thing.permalink + "?context=3")} -
  • + %if not thing.deleted:
  • - ${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)}
  • - %endif - %if thing.deleted: - %if thing.parent_permalink and not thing.profilepage: -
  • - ${self.bylink_button(_("parent"), thing.parent_permalink)} + %if thing.saved: +
  • + ${self.state_button("unsave", _("unsave"), "toggle_save(this)", _("save"))} +
  • + %else: +
  • + ${self.state_button("save", _("save"), "toggle_save(this)", _("unsave"))} +
  • + %endif + %if c.profilepage: +
  • + ${self.bylink_button(_("context"), thing.permalink + "?context=3")} +
  • +
  • + ${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)}
  • %endif - %else: %if not thing.profilepage: %if thing.parent_permalink:
  • diff --git a/r2/r2/templates/usertext.html b/r2/r2/templates/usertext.html index 827aa4237..a5cd3cab5 100644 --- a/r2/r2/templates/usertext.html +++ b/r2/r2/templates/usertext.html @@ -116,8 +116,10 @@
    %endif - ##this is set for both editting selftext and creating new comments - + %if thing.fullname: + ##this is set for both editting selftext and creating new comments + + %endif %if not thing.creating: