mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-30 01:08:32 -05:00
Add moderator permission for wiki.
This commit is contained in:
@@ -593,9 +593,10 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
# The user who made the request must be an admin or a moderator
|
||||
# for the privilege change to succeed.
|
||||
victim = iuser or nuser
|
||||
perm = 'wiki' if type.startswith('wiki') else 'access'
|
||||
if (not c.user_is_admin
|
||||
and (type in self._sr_friend_types
|
||||
and not container.is_moderator_with_perms(c.user, 'access'))):
|
||||
and not container.is_moderator_with_perms(c.user, perm))):
|
||||
abort(403, 'forbidden')
|
||||
if (type == 'moderator' and not
|
||||
(c.user_is_admin or container.can_demod(c.user, victim))):
|
||||
@@ -687,9 +688,10 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
|
||||
# The user who made the request must be an admin or a moderator
|
||||
# for the privilege change to succeed.
|
||||
perm = 'wiki' if type.startswith('wiki') else 'access'
|
||||
if (not c.user_is_admin
|
||||
and type in self._sr_friend_types
|
||||
and (not container.is_moderator_with_perms(c.user, 'access')
|
||||
and (not container.is_moderator_with_perms(c.user, perm)
|
||||
or c.user._spam)):
|
||||
if c.user._spam:
|
||||
return
|
||||
|
||||
@@ -611,12 +611,12 @@ class FrontController(RedditController, OAuth2ResourceController):
|
||||
pane = ModList(editable=is_unlimited_moderator)
|
||||
elif is_moderator_with_perms('access') and location == 'banned':
|
||||
pane = BannedList(editable=is_moderator_with_perms('access'))
|
||||
elif is_moderator_with_perms('access') and location == 'wikibanned':
|
||||
elif is_moderator_with_perms('wiki') and location == 'wikibanned':
|
||||
pane = WikiBannedList(editable=is_moderator_with_perms('access'))
|
||||
elif (is_moderator_with_perms('access')
|
||||
elif (is_moderator_with_perms('wiki')
|
||||
and location == 'wikicontributors'):
|
||||
pane = WikiMayContributeList(
|
||||
editable=is_moderator_with_perms('access'))
|
||||
editable=is_moderator_with_perms('wiki'))
|
||||
elif (location == 'contributors' and
|
||||
# On public reddits, only moderators can see the whitelist.
|
||||
# On private reddits, all contributors can see each other.
|
||||
|
||||
@@ -254,7 +254,9 @@ class WikiController(RedditController):
|
||||
c.wiki_api_url = join_urls(c.site.path, '/api/wiki')
|
||||
c.wiki_id = g.default_sr if frontpage else c.site.name
|
||||
self.editconflict = False
|
||||
c.is_wiki_mod = (c.user_is_admin or c.site.is_moderator(c.user)) if c.user_is_loggedin else False
|
||||
c.is_wiki_mod = (
|
||||
c.user_is_admin or c.site.is_moderator_with_perms(c.user, 'wiki')
|
||||
) if c.user_is_loggedin else False
|
||||
c.wikidisabled = False
|
||||
|
||||
mode = c.site.wikimode
|
||||
|
||||
@@ -383,7 +383,9 @@ class Reddit(Templated):
|
||||
moderator = c.user_is_loggedin and (c.user_is_admin or
|
||||
c.site.is_moderator(c.user))
|
||||
if self.show_wiki_actions:
|
||||
ps.append(self.wiki_actions_menu(moderator=moderator))
|
||||
menu = self.wiki_actions_menu(
|
||||
moderator=c.site.is_moderator_with_perms(c.user, 'wiki'))
|
||||
ps.append(menu)
|
||||
if moderator:
|
||||
ps.append(self.sr_admin_menu())
|
||||
if show_adbox:
|
||||
@@ -483,7 +485,8 @@ class Reddit(Templated):
|
||||
|
||||
mod = False
|
||||
if c.user_is_loggedin:
|
||||
mod = bool(c.user_is_admin or c.site.is_moderator(c.user))
|
||||
mod = bool(c.user_is_admin
|
||||
or c.site.is_moderator_with_perms(c.user, 'wiki'))
|
||||
if c.site._should_wiki and (c.site.wikimode != 'disabled' or mod):
|
||||
if not g.disable_wiki:
|
||||
main_buttons.append(NavButton('wiki', 'wiki'))
|
||||
|
||||
@@ -92,6 +92,10 @@ class ModeratorPermissionSet(PermissionSet):
|
||||
description=_(
|
||||
'use the approve, remove, spam, distinguish, and nsfw buttons'),
|
||||
),
|
||||
wiki=dict(
|
||||
title=_('wiki'),
|
||||
description=_('manage the wiki and access to the wiki'),
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -74,7 +74,7 @@ def this_may_view(page):
|
||||
return may_view(c.site, user, page)
|
||||
|
||||
def may_revise(sr, user, page=None):
|
||||
if sr.is_moderator(user):
|
||||
if sr.is_moderator_with_perms(user, 'wiki'):
|
||||
# Mods may always contribute
|
||||
return True
|
||||
|
||||
@@ -145,7 +145,7 @@ def may_revise(sr, user, page=None):
|
||||
|
||||
def may_view(sr, user, page):
|
||||
# User being None means not logged in
|
||||
mod = sr.is_moderator(user) if user else False
|
||||
mod = sr.is_moderator_with_perms(user, 'wiki') if user else False
|
||||
|
||||
if mod:
|
||||
# Mods may always view
|
||||
|
||||
Reference in New Issue
Block a user