mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-29 00:38:11 -05:00
Add gold-restricted subreddits
Viewable by anyone, but only gold members can submit or comment. Can only be set by admins.
This commit is contained in:
@@ -1704,7 +1704,7 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
show_media = VBoolean('show_media'),
|
||||
exclude_banned_modqueue = VBoolean('exclude_banned_modqueue'),
|
||||
show_cname_sidebar = VBoolean('show_cname_sidebar'),
|
||||
type = VOneOf('type', ('public', 'private', 'restricted', 'archived')),
|
||||
type = VOneOf('type', ('public', 'private', 'restricted', 'gold_restricted', 'archived')),
|
||||
link_type = VOneOf('link_type', ('any', 'link', 'self')),
|
||||
submit_link_label=VLength('submit_link_label', max_length=60),
|
||||
submit_text_label=VLength('submit_text_label', max_length=60),
|
||||
@@ -1803,6 +1803,10 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
if kw['type'] == 'archived' and not can_set_archived:
|
||||
c.errors.add(errors.INVALID_OPTION, field='type')
|
||||
|
||||
can_set_gold_restricted = c.user_is_admin or (sr and sr.type == 'gold_restricted')
|
||||
if kw['type'] == 'gold_restricted' and not can_set_gold_restricted:
|
||||
c.errors.add(errors.INVALID_OPTION, field='type')
|
||||
|
||||
if not sr and form.has_errors("ratelimit", errors.RATELIMIT):
|
||||
pass
|
||||
elif not sr and form.has_errors("name", errors.SUBREDDIT_EXISTS,
|
||||
|
||||
@@ -353,7 +353,9 @@ class Reddit(Templated):
|
||||
and (c.user_is_loggedin or not g.read_only_mode)
|
||||
and not user_banned):
|
||||
if (not isinstance(c.site, FakeSubreddit)
|
||||
and c.site.type in ("archived", "restricted")
|
||||
and c.site.type in ("archived",
|
||||
"restricted",
|
||||
"gold_restricted")
|
||||
and not (c.user_is_loggedin
|
||||
and c.site.can_submit(c.user))):
|
||||
if c.site.type == "archived":
|
||||
@@ -365,8 +367,12 @@ class Reddit(Templated):
|
||||
subtitles=[subtitle],
|
||||
show_icon=False))
|
||||
else:
|
||||
subtitle = _('submission in this subreddit '
|
||||
'is restricted to approved submitters.')
|
||||
if c.site.type == 'restricted':
|
||||
subtitle = _('submission in this subreddit '
|
||||
'is restricted to approved submitters.')
|
||||
elif c.site.type == 'gold_restricted':
|
||||
subtitle = _('submission in this subreddit '
|
||||
'is restricted to reddit gold members.')
|
||||
ps.append(SideBox(title=_('Submissions restricted'),
|
||||
css_class="submit",
|
||||
disabled=True,
|
||||
|
||||
@@ -57,7 +57,7 @@ def cache_lists():
|
||||
continue
|
||||
|
||||
type = getattr(sr, 'type', 'private')
|
||||
if type not in ('public', 'restricted'):
|
||||
if type not in ('public', 'restricted', 'gold_restricted'):
|
||||
# skips reddits that can't appear in the default list
|
||||
# because of permissions
|
||||
continue
|
||||
|
||||
@@ -336,6 +336,8 @@ class Subreddit(Thing, Printable):
|
||||
return True
|
||||
elif self.is_banned(user):
|
||||
return False
|
||||
elif self.type == 'gold_restricted' and user.gold:
|
||||
return True
|
||||
elif self.type in ('public','restricted'):
|
||||
return True
|
||||
elif self.is_moderator(user) or self.is_contributor(user):
|
||||
@@ -356,6 +358,8 @@ class Subreddit(Thing, Printable):
|
||||
elif self.is_moderator(user) or self.is_contributor(user):
|
||||
#restricted/private require contributorship
|
||||
return True
|
||||
elif self.type == 'gold_restricted' and user.gold:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -453,7 +457,8 @@ class Subreddit(Thing, Printable):
|
||||
|
||||
if self.spammy():
|
||||
return False
|
||||
elif self.type in ('public', 'restricted', 'archived'):
|
||||
elif self.type in ('public', 'restricted',
|
||||
'gold_restricted', 'archived'):
|
||||
return True
|
||||
elif c.user_is_loggedin:
|
||||
return (self.is_contributor(user) or
|
||||
|
||||
@@ -133,6 +133,13 @@
|
||||
_("anyone can view, but submissions are no longer accepted"),
|
||||
is_archived)}
|
||||
%endif
|
||||
|
||||
<% is_gold_restricted = thing.site and thing.site.type == 'gold_restricted' %>
|
||||
%if c.user_is_admin or is_gold_restricted:
|
||||
${utils.radio_type('type', "gold_restricted", _("gold restricted"),
|
||||
_("anyone can view, but only reddit gold members can submit or comment"),
|
||||
is_gold_restricted)}
|
||||
%endif
|
||||
</table>
|
||||
${error_field("INVALID_OPTION", "type")}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user