Add option to make subreddit traffic stats page public

This commit is contained in:
Bryce Boe
2012-01-07 18:24:37 -08:00
committed by Neil Williams
parent 692f0c12d7
commit 5430a4c4ea
5 changed files with 14 additions and 2 deletions

View File

@@ -1736,6 +1736,7 @@ class ApiController(RedditController, OAuth2ResourceController):
over_18 = VBoolean('over_18'),
allow_top = VBoolean('allow_top'),
show_media = VBoolean('show_media'),
public_traffic = VBoolean('public_traffic'),
exclude_banned_modqueue = VBoolean('exclude_banned_modqueue'),
show_cname_sidebar = VBoolean('show_cname_sidebar'),
type = VOneOf('type', ('public', 'private', 'restricted', 'gold_restricted', 'archived')),
@@ -1785,7 +1786,7 @@ class ApiController(RedditController, OAuth2ResourceController):
kw = dict((k, v) for k, v in kw.iteritems()
if k in ('name', 'title', 'domain', 'description',
'show_media', 'exclude_banned_modqueue',
'show_cname_sidebar', 'type',
'show_cname_sidebar', 'type', 'public_traffic',
'link_type', 'submit_link_label', 'comment_score_hide_mins',
'submit_text_label', 'lang', 'css_on_cname',
'header_title', 'over_18', 'wikimode', 'wiki_edit_karma',

View File

@@ -638,7 +638,8 @@ class FrontController(RedditController, OAuth2ResourceController):
stylesheet = (c.site.stylesheet_contents_user or
c.site.stylesheet_contents)
pane = SubredditStylesheetSource(stylesheet_contents=stylesheet)
elif (is_moderator or c.user_is_sponsor) and location == 'traffic':
elif location == 'traffic' and (c.site.public_traffic or
(is_moderator or c.user_is_sponsor)):
pane = trafficpages.SubredditTraffic()
elif (location == "about") and is_api():
return self.redirect(add_sr('about.json'), code=301)

View File

@@ -135,6 +135,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'over_18': _('toggle viewers must be over 18'),
'allow_top': _('toggle allow in default set'),
'show_media': _('toggle show thumbnail images of content'),
'public_traffic': _('toggle public traffic stats page'),
'exclude_banned_modqueue': _('toggle exclude banned users\' posts from modqueue'),
'domain': _('domain'),
'show_cname_sidebar': _('toggle show sidebar from cname'),

View File

@@ -104,6 +104,7 @@ class Subreddit(Thing, Printable):
prev_public_description_id = "",
allow_comment_gilding=True,
hide_subscribers=False,
public_traffic=False,
)
_essentials = ('type', 'name', 'lang')
_data_int_props = Thing._data_int_props + ('mod_actions', 'reported',

View File

@@ -264,6 +264,14 @@
${_("exclude posts by site-wide banned users from modqueue")}
</label>
</li>
<li>
<input class="nomargin" type="checkbox"
name="public_traffic" id="public_traffic"
${thing.site and thing.site.public_traffic and "checked='checked'" or ""}>
<label for="public_traffic">
${_("make the traffic stats page available to everyone")}
</label>
</li>
</ul>
</div>
<div class="usertext-edit">