diff --git a/ckanext/harvest/helpers.py b/ckanext/harvest/helpers.py index c43ecfd..d00a27c 100644 --- a/ckanext/harvest/helpers.py +++ b/ckanext/harvest/helpers.py @@ -1,5 +1,4 @@ -from pylons import request from ckan import logic from ckan import model import ckan.lib.helpers as h @@ -9,6 +8,9 @@ from ckanext.harvest.model import UPDATE_FREQUENCIES from ckanext.harvest.plugin import DATASET_TYPE_NAME from ckanext.harvest.interfaces import IHarvester +request = p.toolkit.request + + def package_list_for_source(source_id): ''' Creates a dataset list with the ones belonging to a particular harvest diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index a197144..2261422 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -1,6 +1,7 @@ -import types +import json from logging import getLogger +from six import string_types from sqlalchemy.util import OrderedDict from ckan import logic @@ -175,12 +176,11 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): return 'source/edit.html' def setup_template_variables(self, context, data_dict): - - p.toolkit.c.harvest_source = p.toolkit.c.pkg_dict + if hasattr(p.toolkit.c, 'pkg'): + p.toolkit.c.harvest_source = p.toolkit.c.pkg p.toolkit.c.dataset_type = DATASET_TYPE_NAME - def create_package_schema(self): ''' Returns the schema for mapping package data from a form to a format @@ -263,6 +263,18 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): p.toolkit.add_resource('fanstatic_library', 'ckanext-harvest') p.toolkit.add_resource('public/ckanext/harvest/javascript', 'harvest-extra-field') + if p.toolkit.check_ckan_version(min_version='2.9.0'): + mappings = config.get('ckan.legacy_route_mappings', {}) + if isinstance(mappings, string_types): + mappings = json.loads(mappings) + + mappings.update({ + 'harvest_read': 'harvest.read', + 'harvest_edit': 'harvest.edit', + }) + # https://github.com/ckan/ckan/pull/4521 + config['ckan.legacy_route_mappings'] = json.dumps(mappings) + ## IActions def get_actions(self): diff --git a/ckanext/harvest/templates/source/admin_base.html b/ckanext/harvest/templates/source/admin_base.html index 7334281..e6ebba5 100644 --- a/ckanext/harvest/templates/source/admin_base.html +++ b/ckanext/harvest/templates/source/admin_base.html @@ -8,42 +8,41 @@ {% endblock %} {% block action_links %} - {% set show_li = c.__version__.startswith('2.0') %} {% if source.status and source.status.last_job and (source.status.last_job.status == 'New' or source.status.last_job.status == 'Running') %} - {{ '