From fae672ea8ef4cdb862e4458dea114775f9775813 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Tue, 4 Aug 2015 15:34:24 -0600 Subject: [PATCH] Quarantine: hide subscribers / users here now This hides the display of the subscribers and "users here now" counts for quarantined subreddits. 0 will be returned for both values through the API. --- r2/r2/lib/jsontemplates.py | 3 ++- r2/r2/models/subreddit.py | 12 +++++++++++- r2/r2/templates/subredditinfobar.html | 10 ++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index e14dd36f9..273693397 100644 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -353,7 +353,8 @@ class SubredditJsonTemplate(ThingJsonTemplate): if attr not in self._public_attrs and not thing.can_view(c.user): return None - if attr == "_ups" and thing.hide_subscribers: + if (attr == "_ups" and + (thing.hide_subscribers or thing.hide_num_users_info)): return 0 elif attr == 'description_html': return safemarkdown(thing.description) diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index cb216c925..03f681369 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -572,6 +572,9 @@ class Subreddit(Thing, Printable, BaseSite): @property def accounts_active(self): + if self.hide_num_users_info: + return 0 + return self.get_accounts_active()[0] @property @@ -586,6 +589,10 @@ class Subreddit(Thing, Printable, BaseSite): def hide_contributors(self): return self.type in {'employees_only', 'gold_only'} + @property + def hide_num_users_info(self): + return self.quarantine + @property def _related_multipath(self): return '/r/%s/m/related' % self.name.lower() @@ -930,7 +937,10 @@ class Subreddit(Thing, Printable, BaseSite): if item.hide_subscribers and not c.user_is_admin: item._ups = 0 - item.score_hidden = not item.can_view(user) + item.score_hidden = ( + not item.can_view(user) or + item.hide_num_users_info + ) item.score = item._ups diff --git a/r2/r2/templates/subredditinfobar.html b/r2/r2/templates/subredditinfobar.html index 73950cd74..20713af89 100644 --- a/r2/r2/templates/subredditinfobar.html +++ b/r2/r2/templates/subredditinfobar.html @@ -53,10 +53,12 @@ %endif ${SubscribeButton(thing.sr)} - ${unsafe(Score.readers(thing.subscribers))} -

- ${unsafe(Score.users_here_now(thing.accounts_active, prepend='~' if thing.accounts_active_fuzzed else ''))} -

+ %if not thing.sr.hide_num_users_info: + ${unsafe(Score.readers(thing.subscribers))} +

+ ${unsafe(Score.users_here_now(thing.accounts_active, prepend='~' if thing.accounts_active_fuzzed else ''))} +

+ %endif %if thing.sr.moderator: