From 54a40d4b2f70f36d8ecb47b04a2021f306571d96 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Thu, 13 Jun 2013 14:24:21 -0600 Subject: [PATCH] Add approval checkmark to comments as well --- r2/r2/models/builder.py | 20 ++++++++++++++++++++ r2/r2/models/link.py | 21 --------------------- r2/r2/public/static/css/reddit.less | 4 ++++ r2/r2/templates/comment.html | 1 + r2/r2/templates/link.html | 9 +-------- r2/r2/templates/printable.html | 11 ++++++++++- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/r2/r2/models/builder.py b/r2/r2/models/builder.py index 99ba4e081..8726cb00d 100755 --- a/r2/r2/models/builder.py +++ b/r2/r2/models/builder.py @@ -267,6 +267,26 @@ class Builder(object): and item.sr_id in can_own_flair_set)))): w.can_flair = True + w.approval_checkmark = None + if w.can_ban: + verdict = getattr(w, "verdict", None) + if verdict in ('admin-approved', 'mod-approved'): + approver = None + baninfo = getattr(w, "ban_info", None) + if baninfo: + approver = baninfo.get("unbanner", None) + approval_time = baninfo.get("unbanned_at", None) + + approver = approver or _("a moderator") + + if approval_time: + text = _("approved by %(who)s %(when)s ago") % { + "who": approver, + "when": timesince(approval_time)} + else: + text = _("approved by %s") % approver + w.approval_checkmark = text + # recache the user object: it may be None if user is not logged in, # whereas now we are happy to have the UnloggedUser object user = c.user diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index f167eec9e..7acd0b641 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -542,33 +542,12 @@ class Link(Thing, Printable): item.author = DeletedUser() item.as_deleted = True - item.approval_checkmark = None - item_age = datetime.now(g.tz) - item._date if item_age.days > g.VOTE_AGE_LIMIT and item.promoted is None: item.votable = False else: item.votable = True - if item.can_ban: - verdict = getattr(item, "verdict", None) - if verdict in ('admin-approved', 'mod-approved'): - approver = None - baninfo = getattr(item, "ban_info", None) - if baninfo: - approver = baninfo.get("unbanner", None) - approval_time = baninfo.get("unbanned_at", None) - - approver = approver or _("a moderator") - - if approval_time: - text = _("approved by %(who)s %(when)s ago") % { - "who": approver, - "when": timesince(approval_time)} - else: - text = _("approved by %s") % approver - item.approval_checkmark = text - item.expunged = False if item.is_self: item.expunged = Link._should_expunge_selftext(item) diff --git a/r2/r2/public/static/css/reddit.less b/r2/r2/public/static/css/reddit.less index d827b3c05..a871f9080 100755 --- a/r2/r2/public/static/css/reddit.less +++ b/r2/r2/public/static/css/reddit.less @@ -3323,6 +3323,10 @@ form input[type=radio] {margin: 2px .5em 0 0; } margin-left: 3px; } +.tagline .approval-checkmark { + height: 1em; +} + .little { font-size: smaller } .gray { color: gray } diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index 2f83f9eb1..ab1c80f5c 100755 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -137,6 +137,7 @@ ${parent.collapsed()} ${ungettext("child", "children", thing.num_children)}) %endif + ${self.approval_checkmark()} <%def name="Child()"> diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index 05da43d24..c1ac6a3a0 100755 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -25,7 +25,6 @@ from r2.lib.template_helpers import s3_https_if_secure from r2.lib.pages.things import LinkButtons from r2.lib.pages import WrappedUser - from r2.lib.template_helpers import static from r2.lib.strings import Score, strings %> @@ -93,13 +92,7 @@ %if c.site.link_flair_position == 'right': <%call expr="flair()" /> %endif - %if getattr(thing, "approval_checkmark", None): - - %endif + ${self.approval_checkmark()} ${self.domain()} diff --git a/r2/r2/templates/printable.html b/r2/r2/templates/printable.html index 8b4d644b4..1c371377a 100644 --- a/r2/r2/templates/printable.html +++ b/r2/r2/templates/printable.html @@ -21,7 +21,7 @@ ############################################################################### <%! - from r2.lib.template_helpers import add_sr + from r2.lib.template_helpers import add_sr, static from r2.lib.strings import strings from r2.lib.pages.things import BanButtons %> @@ -45,6 +45,15 @@ ${self.RenderPrintable()} %endif +<%def name="approval_checkmark()"> + %if getattr(thing, "approval_checkmark", None): + + %endif + + <%def name="thing_css_class(what)">thing id-${what._fullname} <%def name="thing_css_rowclass(what)">