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
This commit is contained in:
Chad Birch
2013-04-29 17:19:36 -06:00
parent 398fc0e1a3
commit 8eac5bf1e6
3 changed files with 7 additions and 1 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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>
<%def name="midcol(display=True, cls = '')">