From b6c457aa136ba38274cabaedf42caa5875199acb Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Wed, 26 Jun 2013 15:28:52 -0700 Subject: [PATCH] Make it possible to hide subscribers on arbitrary subreddits. This is a generalization of existing code for /r/lounge intended to allow similar hiding for /r/elves. --- r2/r2/lib/jsontemplates.py | 4 +--- r2/r2/lib/pages/pages.py | 2 +- r2/r2/models/subreddit.py | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 2f6a5aed8..049672196 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -232,9 +232,7 @@ class SubredditJsonTemplate(ThingJsonTemplate): ) def thing_attr(self, thing, attr): - # Don't reveal revenue information via /r/lounge's subscribers - if (attr == "_ups" and g.lounge_reddit - and thing.name == g.lounge_reddit): + if attr == "_ups" and thing.hide_subscribers: return 0 # Don't return accounts_active counts in /subreddits elif (attr == "accounts_active" and isinstance(c.site, SubSR)): diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 44c3d0bac..c5da4fa61 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -3013,7 +3013,7 @@ class ContributorList(UserList): return _("approved submitters for %(reddit)s") % dict(reddit = c.site.name) def user_ids(self): - if c.site.name == g.lounge_reddit: + if c.site.hide_subscribers: return [] # /r/lounge has too many subscribers to load without timing out, # and besides, some people might not want this list to be so # easily accessible. diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index 3d1442f31..4a4dcd0cb 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -103,6 +103,7 @@ class Subreddit(Thing, Printable): prev_description_id = "", prev_public_description_id = "", allow_comment_gilding=True, + hide_subscribers=False, ) _essentials = ('type', 'name', 'lang') _data_int_props = Thing._data_int_props + ('mod_actions', 'reported', @@ -561,9 +562,7 @@ class Subreddit(Thing, Printable): (item.moderator or rels.get((item, user, 'contributor')))) - # Don't reveal revenue information via /r/lounge's subscribers - if (g.lounge_reddit and item.name == g.lounge_reddit - and not c.user_is_admin): + if item.hide_subscribers and not c.user_is_admin: item._ups = 0 item.score = item._ups