Mercurial > wikked
changeset 473:93d84f2c2b31
web: Prevent editing pages in a read-only endpoint.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 08 Oct 2018 23:47:02 -0700 |
parents | dbe22d170cf7 |
children | db73b12ad212 |
files | wikked/webimpl/__init__.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/wikked/webimpl/__init__.py Mon Oct 08 23:46:08 2018 -0700 +++ b/wikked/webimpl/__init__.py Mon Oct 08 23:47:02 2018 -0700 @@ -85,6 +85,15 @@ if check_perms is not None: user, modes = check_perms + + if 'edit' in modes: + endpoint, path = split_page_url(url) + if endpoint: + epinfo = wiki.getEndpoint(endpoint) + if epinfo is not None and epinfo.readonly: + msg = "The '%s' endpoint is read-only." % endpoint + raise UserPermissionError('edit', msg) + has_page_perm = page.wiki.auth.hasPagePermission for mode in modes.split(','): if not has_page_perm(page, user, PERM_NAMES[mode]):