Skip to content

Commit

Permalink
Merge branch 'master' into package-blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Apr 30, 2018
2 parents 3eec357 + 6142248 commit c152675
Show file tree
Hide file tree
Showing 25 changed files with 1,124 additions and 317 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -45,6 +45,7 @@ RUN mkdir -p $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH && \
# Setup CKAN
ADD . $CKAN_VENV/src/ckan/
RUN ckan-pip install -U pip && \
ckan-pip install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirement-setuptools.txt && \
ckan-pip install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirements.txt && \
ckan-pip install -e $CKAN_VENV/src/ckan/ && \
ln -s $CKAN_VENV/src/ckan/ckan/config/who.ini $CKAN_CONFIG/who.ini && \
Expand Down
2 changes: 1 addition & 1 deletion ckan/config/environment.py
Expand Up @@ -94,7 +94,7 @@ def find_controller(self, controller):
pylons_config.init_app(global_conf, app_conf, package='ckan', paths=paths)

# Update the main CKAN config object with the Pylons specific stuff, as it
# quite hard to keep them separated. This should be removed once Pylons
# is quite hard to keep them separated. This should be removed once Pylons
# support is dropped
config.update(pylons_config)

Expand Down
3 changes: 3 additions & 0 deletions ckan/lib/cli.py
Expand Up @@ -2007,6 +2007,9 @@ def less(self):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
output = process.communicate()
directory = output[0].strip()
if not directory:
raise error('Command "{}" returned nothing. Check that npm is '
'installed.'.format(command))
less_bin = os.path.join(directory, 'lessc')

public = config.get(u'ckan.base_public_folder')
Expand Down
24 changes: 24 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -65,6 +65,11 @@
MARKDOWN_ATTRIBUTES = copy.deepcopy(ALLOWED_ATTRIBUTES)
MARKDOWN_ATTRIBUTES.setdefault('img', []).extend(['src', 'alt', 'title'])

LEGACY_ROUTE_NAMES = {
'home': 'home.index',
'about': 'home.about',
}


class HelperAttributeDict(dict):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -305,6 +310,9 @@ def url_for(*args, **kw):
_auto_flask_context.push()

# First try to build the URL with the Flask router
# Temporary mapping for pylons to flask route names
if len(args):
args = (map_pylons_to_flask_route_name(args[0]),)
my_url = _url_for_flask(*args, **kw)

except FlaskRouteBuildError:
Expand Down Expand Up @@ -873,6 +881,21 @@ def build_nav(menu_item, title, **kw):
return _make_menu_item(menu_item, title, icon=None, **kw)


def map_pylons_to_flask_route_name(menu_item):
'''returns flask routes for old fashioned route names'''
# Pylons to Flask legacy route names mappings
if config.get('ckan.legacy_route_mappings'):
if isinstance(config.get('ckan.legacy_route_mappings'), string_types):
LEGACY_ROUTE_NAMES.update(json.loads(config.get(
'ckan.legacy_route_mappings')))

if menu_item in LEGACY_ROUTE_NAMES:
log.info('Route name "{}" is deprecated and will be removed.\
Please update calls to use "{}" instead'.format(
menu_item, LEGACY_ROUTE_NAMES[menu_item]))
return LEGACY_ROUTE_NAMES.get(menu_item, menu_item)


@core_helper
def build_extra_admin_nav():
'''Build extra navigation items used in ``admin/base.html`` for values
Expand Down Expand Up @@ -906,6 +929,7 @@ def _make_menu_item(menu_item, title, **kw):
This function is called by wrapper functions.
'''
menu_item = map_pylons_to_flask_route_name(menu_item)
_menu_items = config['routes.named_routes']
if menu_item not in _menu_items:
raise Exception('menu item `%s` cannot be found' % menu_item)
Expand Down

0 comments on commit c152675

Please sign in to comment.