From 8eac5bf1e6141cb7cebd38876f61479e2bde0ed8 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Mon, 29 Apr 2013 17:19:36 -0600 Subject: [PATCH] Add indicators of hidden score to API and HTML If the score is hidden, data-ups and data-downs will both be 0, and the comment will also have the "score-hidden" class --- r2/r2/lib/jsontemplates.py | 1 + r2/r2/models/link.py | 1 + r2/r2/templates/comment.html | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 4fb8718dd..cc5f395d4 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -369,6 +369,7 @@ class PromotedLinkJsonTemplate(LinkJsonTemplate): class CommentJsonTemplate(ThingJsonTemplate): _data_attrs_ = ThingJsonTemplate.data_attrs(ups = "upvotes", downs = "downvotes", + score_hidden = "score_hidden", replies = "child", body = "body", body_html = "body_html", diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index c6406f54e..0ba6394da 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -1057,6 +1057,7 @@ class Comment(Thing, Printable): item.score = 1 item.score_hidden = True item.voting_score = [1, 1, 1] + item.render_css_class += " score-hidden" else: item.score_hidden = False diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index cf8d7fd1d..63535b66b 100755 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -34,7 +34,11 @@ ################## <%def name="thing_data_attributes(what)" buffered="True"> -${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${what.downvotes}" + %if what.score_hidden: + ${parent.thing_data_attributes(what)} data-ups="0" data-downs="0" + %else: + ${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${what.downvotes}" + %endif <%def name="midcol(display=True, cls = '')">