# HG changeset patch # User Mads Kiilerich # Date 2020-10-10 20:43:52 # Node ID bc1fff7ae770b5d177fb91222faf951462f0e7e9 # Parent 0be48652ca48533f4bef11686f76cbaf85e6c988 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. diff --git a/kallithea/__init__.py b/kallithea/__init__.py --- a/kallithea/__init__.py +++ b/kallithea/__init__.py @@ -45,6 +45,8 @@ CELERY_EAGER = False CONFIG = {} +# URL prefix for non repository related links - must start with `/` +ADMIN_PREFIX = '/_admin' URL_SEP = '/' # Linked module for extensions diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py --- a/kallithea/config/routing.py +++ b/kallithea/config/routing.py @@ -21,13 +21,10 @@ refer to the routes manual at http://rou 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 @@ def make_map(config): 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", diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py --- a/kallithea/model/validators.py +++ b/kallithea/model/validators.py @@ -28,7 +28,6 @@ from sqlalchemy import func 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 @@ def ValidRepoName(edit=False, old_data=N 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)