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.
This commit is contained in:
Neil Williams
2013-06-26 15:28:52 -07:00
parent 92c5508799
commit b6c457aa13
3 changed files with 4 additions and 7 deletions

View File

@@ -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)):

View File

@@ -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.

View File

@@ -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