Mercurial > kallithea
changeset 8680:bc1fff7ae770
routing: move ADMIN_PREFIX constant from routing to top level kallithea module
Perhaps not the ideal place, but that is how we handle somewhat similar data.
This avoids an unfortunate dependency from the model to routing.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 10 Oct 2020 20:43:52 +0200 |
parents | 0be48652ca48 |
children | f66a13a8ab99 |
files | kallithea/__init__.py kallithea/config/routing.py kallithea/model/validators.py |
diffstat | 3 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/__init__.py Sat Oct 10 22:13:50 2020 +0200 +++ b/kallithea/__init__.py Sat Oct 10 20:43:52 2020 +0200 @@ -45,6 +45,8 @@ CONFIG = {} +# URL prefix for non repository related links - must start with `/` +ADMIN_PREFIX = '/_admin' URL_SEP = '/' # Linked module for extensions
--- a/kallithea/config/routing.py Sat Oct 10 22:13:50 2020 +0200 +++ b/kallithea/config/routing.py Sat Oct 10 20:43:52 2020 +0200 @@ -21,13 +21,10 @@ import routes +import kallithea from kallithea.lib.utils2 import safe_str -# prefix for non repository related links needs to be prefixed with `/` -ADMIN_PREFIX = '/_admin' - - class Mapper(routes.Mapper): """ Subclassed Mapper with routematch patched to decode "unicode" str url to @@ -120,6 +117,7 @@ rmap.connect('issues_url', 'https://bitbucket.org/conservancy/kallithea/issues', _static=True) # ADMIN REPOSITORY ROUTES + ADMIN_PREFIX = kallithea.ADMIN_PREFIX with rmap.submapper(path_prefix=ADMIN_PREFIX, controller='admin/repos') as m: m.connect("repos", "/repos",
--- a/kallithea/model/validators.py Sat Oct 10 22:13:50 2020 +0200 +++ b/kallithea/model/validators.py Sat Oct 10 20:43:52 2020 +0200 @@ -28,7 +28,6 @@ from tg.i18n import ugettext as _ import kallithea -from kallithea.config.routing import ADMIN_PREFIX from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel from kallithea.lib.compat import OrderedSet from kallithea.lib.exceptions import InvalidCloneUriException, LdapImportError @@ -343,7 +342,7 @@ group_path = value.get('group_path') group_name = value.get('group_name') - if repo_name in [ADMIN_PREFIX, '']: + if repo_name in [kallithea.ADMIN_PREFIX, '']: msg = self.message('invalid_repo_name', state, repo=repo_name) raise formencode.Invalid(msg, value, state, error_dict=dict(repo_name=msg)