Enforce floor of 0 on link scores across render styles

Thanks to @iKevinY for the report. Fixes #1205
This commit is contained in:
Jordan Milne
2014-12-16 07:18:04 -04:00
parent 4cfbf59af5
commit 159c51b2b4
3 changed files with 6 additions and 6 deletions

View File

@@ -2892,7 +2892,7 @@ class FrameToolbar(Wrapped):
nonempty = [w for w in wrapped if hasattr(w, "_fullname")]
Link.add_props(user, nonempty)
for w in wrapped:
w.score_fmt = Score.points
w.score_fmt = Score.safepoints
if not hasattr(w, '_fullname'):
w._fullname = None
w.tblink = add_sr("/s/"+quote(w.url))

View File

@@ -223,7 +223,7 @@ def default_thing_wrapper(**params):
if thing.promoted is not None:
w.render_class = PromotedLink
elif style == 'htmllite':
w.score_fmt = Score.points
w.score_fmt = Score.safepoints
w.should_incr_counts = style != 'htmllite'
return w
params['parent_wrapper'] = _default_thing_wrapper

View File

@@ -426,11 +426,11 @@ class Link(Thing, Printable):
if not hasattr(item, "score_fmt"):
item.score_fmt = Score.number_only
if c.render_style == 'compact':
item.score_fmt = Score.points
item.score_fmt = Score.safepoints
item.pref_compress = user.pref_compress
if user.pref_compress:
item.extra_css_class = "compressed"
item.score_fmt = Score.points
item.score_fmt = Score.safepoints
elif pref_media == 'on' and not user.pref_compress:
show_media = True
elif pref_media == 'subreddit' and item.subreddit.show_media:
@@ -658,7 +658,7 @@ class Link(Thing, Printable):
else:
author_text = " <span>" + _ws("by %(author)s") + "</span>"
if item.editted:
if item.score_fmt == Score.points:
if item.score_fmt in (Score.points, Score.safepoints):
taglinetext = ("<span>" +
_ws("%(score)s submitted %(when)s "
"%(lastedited)s") +
@@ -671,7 +671,7 @@ class Link(Thing, Printable):
taglinetext = _("submitted %(when)s %(lastedited)s "
"by %(author)s")
else:
if item.score_fmt == Score.points:
if item.score_fmt in (Score.points, Score.safepoints):
taglinetext = ("<span>" +
_ws("%(score)s submitted %(when)s") +
"</span>")