From 13e191b65f2d61a34b169be1d47ddc780352e2e7 Mon Sep 17 00:00:00 2001 From: Logan Hanks Date: Tue, 17 Apr 2012 15:17:39 -0700 Subject: [PATCH] Add a user preference for showing link flair. --- r2/r2/controllers/post.py | 1 + r2/r2/lib/pages/pages.py | 6 ++++-- r2/r2/lib/wrapped.pyx | 2 +- r2/r2/models/account.py | 1 + r2/r2/templates/link.compact | 10 ++++++++-- r2/r2/templates/link.html | 2 +- r2/r2/templates/link.htmllite | 10 ++++++---- r2/r2/templates/link.mobile | 10 ++++++++-- r2/r2/templates/prefoptions.html | 2 ++ 9 files changed, 32 insertions(+), 12 deletions(-) diff --git a/r2/r2/controllers/post.py b/r2/r2/controllers/post.py index 408677b6f..c4cd0f8df 100644 --- a/r2/r2/controllers/post.py +++ b/r2/r2/controllers/post.py @@ -91,6 +91,7 @@ class PostController(ApiController): default = g.num_comments), pref_show_stylesheets = VBoolean('show_stylesheets'), pref_show_flair = VBoolean('show_flair'), + pref_show_link_flair = VBoolean('show_link_flair'), pref_no_profanity = VBoolean('no_profanity'), pref_label_nsfw = VBoolean('label_nsfw'), pref_show_promote = VBoolean('show_promote'), diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 98cced933..6f2491a78 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -975,7 +975,8 @@ class CommentPane(Templated): return "_".join(map(str, ["commentpane", self.article._fullname, num, self.sort, self.num, c.lang, self.can_reply, c.render_style, - c.user.pref_show_flair])) + c.user.pref_show_flair, + c.user.pref_show_link_flair])) def __init__(self, article, sort, comment, context, num, **kw): # keys: lang, num, can_reply, render_style @@ -1028,8 +1029,9 @@ class CommentPane(Templated): logged_in = c.user_is_loggedin try: c.user = UnloggedUser([c.lang]) - # Preserve the viewing user's flair preference. + # Preserve the viewing user's flair preferences. c.user.pref_show_flair = user.pref_show_flair + c.user.pref_show_link_flair = user.pref_show_link_flair c.user_is_loggedin = False # render as if not logged in (but possibly with reply buttons) diff --git a/r2/r2/lib/wrapped.pyx b/r2/r2/lib/wrapped.pyx index b8b23f1dd..50ee9d976 100644 --- a/r2/r2/lib/wrapped.pyx +++ b/r2/r2/lib/wrapped.pyx @@ -466,7 +466,7 @@ class CachedTemplate(Templated): c.site.flair_enabled, c.site.flair_position, c.site.link_flair_position, c.user.flair_enabled_in_sr(c.site._id), - c.user.pref_show_flair]) + c.user.pref_show_flair, c.user.pref_show_link_flair]) keys = [make_cachable(x, *a) for x in keys] # add all parameters sent into __init__, using their current value diff --git a/r2/r2/models/account.py b/r2/r2/models/account.py index 24a1435d6..cd6b4fff7 100644 --- a/r2/r2/models/account.py +++ b/r2/r2/models/account.py @@ -74,6 +74,7 @@ class Account(Thing): pref_label_nsfw = True, pref_show_stylesheets = True, pref_show_flair = True, + pref_show_link_flair = True, pref_mark_messages_read = True, pref_threaded_messages = True, pref_collapse_read_messages = False, diff --git a/r2/r2/templates/link.compact b/r2/r2/templates/link.compact index 0fb0236c7..e1d344c2f 100644 --- a/r2/r2/templates/link.compact +++ b/r2/r2/templates/link.compact @@ -32,6 +32,12 @@ <%namespace file="utils.compact" import="icon_button, toggle_button" /> <%namespace file="printablebuttons.html" import="state_button" /> +<%def name="flair()"> + %if c.user.pref_show_link_flair: + ${thing.flair_text} + %endif + +