mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
wiki: Correctly check wiki mod permission scope.
This commit is contained in:
@@ -106,7 +106,7 @@ class WikiBasePage(Reddit):
|
||||
pageactions += [('edit', _("edit"), True)]
|
||||
pageactions += [('revisions/%s' % page, _("history"), False)]
|
||||
pageactions += [('discussions', _("talk"), True)]
|
||||
if c.is_wiki_mod:
|
||||
if c.is_wiki_mod and may_revise:
|
||||
pageactions += [('settings', _("settings"), True)]
|
||||
|
||||
action = context.get('wikiaction', (page, 'wiki'))
|
||||
|
||||
@@ -59,8 +59,9 @@ def this_may_view(page):
|
||||
|
||||
def may_revise(sr, user, page=None):
|
||||
if sr.is_moderator_with_perms(user, 'wiki'):
|
||||
# Mods may always contribute
|
||||
return True
|
||||
# Mods may always contribute to non-config pages
|
||||
if not page or not page.special:
|
||||
return True
|
||||
|
||||
if page and page.restricted and not page.special:
|
||||
# People may not contribute to restricted pages
|
||||
@@ -86,7 +87,11 @@ def may_revise(sr, user, page=None):
|
||||
if page and page.has_editor(user._id36):
|
||||
# If the user is an editor on the page, they may edit
|
||||
return True
|
||||
|
||||
|
||||
if (page and page.special and
|
||||
sr.is_moderator_with_perms(user, 'config')):
|
||||
return True
|
||||
|
||||
if page and page.special:
|
||||
# If this is a special page
|
||||
# (and the user is not a mod or page editor)
|
||||
@@ -186,7 +191,13 @@ page_match_regex = re.compile(r'^[\w_\-/]+\Z')
|
||||
|
||||
class VWikiModerator(VSrModerator):
|
||||
def __init__(self, fatal=False, *a, **kw):
|
||||
VSrModerator.__init__(self, fatal=fatal, *a, **kw)
|
||||
VSrModerator.__init__(self, param='page', fatal=fatal, *a, **kw)
|
||||
|
||||
def run(self, page):
|
||||
self.perms = ['wiki']
|
||||
if page and WikiPage.is_special(page):
|
||||
self.perms += ['config']
|
||||
VSrModerator.run(self)
|
||||
|
||||
class VWikiPageName(Validator):
|
||||
def __init__(self, param, error_on_name_normalized=False, *a, **kw):
|
||||
|
||||
@@ -647,11 +647,12 @@ class WikiRevisionBuilder(QueryBuilder):
|
||||
QueryBuilder.__init__(self, *k, **kw)
|
||||
|
||||
def wrap_items(self, items):
|
||||
from r2.lib.validator.wiki import this_may_revise
|
||||
types = {}
|
||||
wrapped = []
|
||||
for item in items:
|
||||
w = self.wrap(item)
|
||||
w.show_extended = self.show_extended
|
||||
w.show_extended = self.show_extended and this_may_revise()
|
||||
types.setdefault(w.render_class, []).append(w)
|
||||
wrapped.append(w)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user