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.
This commit is contained in:
Chad Birch
2015-08-04 15:34:24 -06:00
committed by Florence Yeun
parent 2d38338eab
commit fae672ea8e
3 changed files with 19 additions and 6 deletions

View File

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

View File

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

View File

@@ -53,10 +53,12 @@
%endif
${SubscribeButton(thing.sr)}
<span class="subscribers">${unsafe(Score.readers(thing.subscribers))}</span>
<p class="users-online ${'fuzzed' if thing.accounts_active_fuzzed else ''}" title="${_('logged-in users viewing this subreddit in the past 15 minutes')}">
${unsafe(Score.users_here_now(thing.accounts_active, prepend='~' if thing.accounts_active_fuzzed else ''))}
</p>
%if not thing.sr.hide_num_users_info:
<span class="subscribers">${unsafe(Score.readers(thing.subscribers))}</span>
<p class="users-online ${'fuzzed' if thing.accounts_active_fuzzed else ''}" title="${_('logged-in users viewing this subreddit in the past 15 minutes')}">
${unsafe(Score.users_here_now(thing.accounts_active, prepend='~' if thing.accounts_active_fuzzed else ''))}
</p>
%endif
%if thing.sr.moderator:
<div class="leavemoderator">