Changeset - bc1fff7ae770
[Not reviewed]
default
0 3 0
Mads Kiilerich (mads) - 5 years ago 2020-10-10 20:43:52
mads@kiilerich.com
Grafted from: 219c5105792a
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.
3 files changed with 5 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -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
kallithea/config/routing.py
Show inline comments
 
@@ -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",
kallithea/model/validators.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)