From 1a3e1dd2a610c77b619cd1f0afebc91ae994248f Mon Sep 17 00:00:00 2001 From: Keith Mitchell Date: Wed, 16 May 2012 11:14:24 -0700 Subject: [PATCH] Make unedited link taglines still translatable In the process, move taglinetext logic to a python file --- r2/r2/models/link.py | 32 ++++++++++++++++++++++++++++++++ r2/r2/templates/link.html | 23 ++++++----------------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 4f97c516c..4e6abc046 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -528,6 +528,38 @@ class Link(Thing, Printable): item.expunged = Link._should_expunge_selftext(item) item.editted = getattr(item, "editted", False) + + taglinetext = '' + if item.different_sr: + author_text = (" " + _("by %(author)s to %(reddit)s") + + "") + else: + author_text = " " + _("by %(author)s") + "" + if item.editted: + if item.score_fmt == Score.points: + taglinetext = ("" + + _("%(score)s submitted %(when)s " + "ago%(lastedited)s") + + "") + taglinetext += author_text + elif item.different_sr: + taglinetext = _("submitted %(when)s ago%(lastedited)s " + "by %(author)s to %(reddit)s") + else: + taglinetext = _("submitted %(when)s ago%(lastedited)s " + "by %(author)s") + else: + if item.score_fmt == Score.points: + taglinetext = ("" + + _("%(score)s submitted %(when)s ago") + + "") + taglinetext += author_text + elif item.different_sr: + taglinetext = _("submitted %(when)s ago by %(author)s " + "to %(reddit)s") + else: + taglinetext = _("submitted %(when)s ago by %(author)s") + item.taglinetext = taglinetext if user_is_loggedin: incr_counts(wrapped) diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index fb8dc8ee5..0e4577bf0 100755 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -222,24 +222,13 @@ ${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${w <%def name="tagline()"> <% - if thing.score_fmt == Score.points: - taglinetext = "" + _("%(score)s submitted %(when)s ago%(lastedited)s") + "" - if thing.different_sr: - taglinetext += " " + _("by %(author)s to %(reddit)s") + "" - else: - taglinetext += " " + _("by %(author)s") + "" - elif thing.different_sr: - taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s to %(reddit)s") - else: - taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s") - taglinetext = taglinetext.replace(" ", " ") + taglinetext = thing.taglinetext.replace(" ", " ") %> - - ${unsafe(taglinetext % dict(reddit = self.subreddit(), - score = capture(self.score, thing, thing.likes, tag='span'), - when = capture(thing_timestamp, thing, thing.timesince), - author = WrappedUser(thing.author, thing.attribs, thing).render(), - lastedited = capture(edited, thing, thing.lastedited) + ${unsafe(taglinetext % dict(reddit=self.subreddit(), + score=capture(self.score, thing, thing.likes, tag='span'), + when=capture(thing_timestamp, thing, thing.timesince), + author=WrappedUser(thing.author, thing.attribs, thing).render(), + lastedited=capture(edited, thing, thing.lastedited) ))}