code simplification in wiki
This commit is contained in:
2
VERSION
2
VERSION
@@ -1 +1 @@
|
||||
Version 2.7.4-stable+timestamp.2013.10.27.22.54.47
|
||||
Version 2.7.4-stable+timestamp.2013.10.27.23.17.07
|
||||
|
||||
@@ -5298,8 +5298,9 @@ class Wiki(object):
|
||||
settings.templates = templates
|
||||
settings.controller = controller
|
||||
settings.function = function
|
||||
settings.groups = groups
|
||||
|
||||
settings.groups = auth.user_groups.values() \
|
||||
if groups is None else groups
|
||||
|
||||
db = auth.db
|
||||
self.env = env or {}
|
||||
self.env['component'] = Wiki.component
|
||||
@@ -5407,17 +5408,12 @@ class Wiki(object):
|
||||
def not_authorized(self, page=None):
|
||||
raise HTTP(401)
|
||||
|
||||
def get_groups(self):
|
||||
if self.settings.groups is not None:
|
||||
return self.settings.groups
|
||||
return self.auth.user_groups.values()
|
||||
|
||||
def can_read(self, page):
|
||||
if 'everybody' in page.can_read or not \
|
||||
self.settings.manage_permissions:
|
||||
return True
|
||||
elif self.auth.user:
|
||||
groups = self.get_groups()
|
||||
groups = self.settings.groups
|
||||
if ('wiki_editor' in groups or
|
||||
set(groups).intersection(set(page.can_read + page.can_edit)) or
|
||||
page.created_by == self.auth.user.id):
|
||||
@@ -5427,7 +5423,7 @@ class Wiki(object):
|
||||
def can_edit(self, page=None):
|
||||
if not self.auth.user:
|
||||
redirect(self.auth.settings.login_url)
|
||||
groups = self.get_groups()
|
||||
groups = self.settings.groups
|
||||
return ('wiki_editor' in groups or
|
||||
(page is None and 'wiki_author' in groups) or
|
||||
not page is None and (
|
||||
@@ -5437,7 +5433,7 @@ class Wiki(object):
|
||||
def can_manage(self):
|
||||
if not self.auth.user:
|
||||
return False
|
||||
groups = self.get_groups()
|
||||
groups = self.settings.groups
|
||||
return 'wiki_editor' in groups
|
||||
|
||||
def can_search(self):
|
||||
@@ -5448,7 +5444,7 @@ class Wiki(object):
|
||||
if self.settings.menu_groups is None:
|
||||
return True
|
||||
else:
|
||||
groups = self.get_groups()
|
||||
groups = self.settings.groups
|
||||
if any(t in self.settings.menu_groups for t in groups):
|
||||
return True
|
||||
return False
|
||||
@@ -5548,17 +5544,6 @@ class Wiki(object):
|
||||
created_on=page.created_on,
|
||||
modified_on=page.modified_on)
|
||||
|
||||
def check_editor(self, role='wiki_editor', act=False):
|
||||
if not self.auth.user:
|
||||
if not act:
|
||||
return False
|
||||
redirect(self.auth.settings.login_url)
|
||||
elif not self.auth.has_membership(role):
|
||||
if not act:
|
||||
return False
|
||||
raise HTTP(401, "Not Authorized")
|
||||
return True
|
||||
|
||||
def edit(self,slug,from_template=0):
|
||||
auth = self.auth
|
||||
db = auth.db
|
||||
|
||||
Reference in New Issue
Block a user