From 8b450af41be2a43a0ab1712db6ccdaf4120e2257 Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Wed, 21 Dec 2022 14:14:14 -0500 Subject: [PATCH 01/74] add unescape for email body --- ckanext/harvest/logic/action/update.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index 090e6e155..d57295db7 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -3,6 +3,7 @@ import hashlib import json import six +import html import logging import datetime @@ -798,6 +799,7 @@ def prepare_summary_mail(context, source_id, status): def prepare_error_mail(context, source_id, status): extra_vars = get_mail_extra_vars(context, source_id, status) body = render('emails/error_email.txt', extra_vars) + body = html.unescape(body) subject = '{} - Harvesting Job - Error Notification'\ .format(config.get('ckan.site_title')) From 84780a9633893dd0ffe8f269fb2141f3bbe4d1aa Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Thu, 22 Dec 2022 16:45:18 -0500 Subject: [PATCH 02/74] specify different unescape package for python3.4+ and python2 user --- ckanext/harvest/logic/action/update.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index d57295db7..3fa528c0a 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -3,7 +3,6 @@ import hashlib import json import six -import html import logging import datetime @@ -799,7 +798,13 @@ def prepare_summary_mail(context, source_id, status): def prepare_error_mail(context, source_id, status): extra_vars = get_mail_extra_vars(context, source_id, status) body = render('emails/error_email.txt', extra_vars) - body = html.unescape(body) + if six.PY34: + import html + body = html.unescape(body) + elif six.PY2: + import HTMLParser + body = HTMLParser.HTMLParser().unescape(body) + subject = '{} - Harvesting Job - Error Notification'\ .format(config.get('ckan.site_title')) From 9338de78a86425d5334e1c8fbb33459f04e4f1cc Mon Sep 17 00:00:00 2001 From: Jin-Sun-tts Date: Thu, 22 Dec 2022 16:48:12 -0500 Subject: [PATCH 03/74] fix lint --- ckanext/harvest/logic/action/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index 3fa528c0a..c669ac4ba 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -804,7 +804,7 @@ def prepare_error_mail(context, source_id, status): elif six.PY2: import HTMLParser body = HTMLParser.HTMLParser().unescape(body) - + subject = '{} - Harvesting Job - Error Notification'\ .format(config.get('ckan.site_title')) From 2f59c0d5f02e08483e828d432ba192f090b155cb Mon Sep 17 00:00:00 2001 From: Fuhu Xia Date: Wed, 15 Feb 2023 17:12:31 -0500 Subject: [PATCH 04/74] pick the right harvest_object_id if there are multiple --- ckanext/harvest/logic/action/get.py | 5 +++-- ckanext/harvest/plugin/__init__.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ckanext/harvest/logic/action/get.py b/ckanext/harvest/logic/action/get.py index cc1ec4c19..498152e88 100644 --- a/ckanext/harvest/logic/action/get.py +++ b/ckanext/harvest/logic/action/get.py @@ -267,8 +267,9 @@ def harvest_object_show(context, data_dict): obj = model.Session.query(HarvestObject) \ .filter(HarvestObject.package_id == pkg.id) \ .filter( - HarvestObject.current == True # noqa: E712 - ).first() + HarvestObject.current == True # noqa: E712 + ).order_by(HarvestObject.import_finished.desc()) \ + .first() else: raise p.toolkit.ValidationError( 'Please provide either an "id" or a "dataset_id" parameter') diff --git a/ckanext/harvest/plugin/__init__.py b/ckanext/harvest/plugin/__init__.py index 3c22c6a83..a2a0b4f54 100644 --- a/ckanext/harvest/plugin/__init__.py +++ b/ckanext/harvest/plugin/__init__.py @@ -120,7 +120,10 @@ def before_dataset_index(self, pkg_dict): harvest_object = model.Session.query(HarvestObject) \ .filter(HarvestObject.package_id == pkg_dict["id"]) \ - .filter(HarvestObject.current == True).first() # noqa + .filter( + HarvestObject.current == True # noqa + ).order_by(HarvestObject.import_finished.desc()) \ + .first() if harvest_object: From a47a4f1a4fa0d91f42846a16f42c0822b1e6657d Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 09:04:07 -0300 Subject: [PATCH 05/74] Drop support for Pylons --- .github/workflows/test.yml | 12 +--- ckanext/harvest/harvesters/base.py | 21 +----- ckanext/harvest/plugin/__init__.py | 21 +----- ckanext/harvest/plugin/pylons_plugin.py | 88 ------------------------- 4 files changed, 7 insertions(+), 135 deletions(-) delete mode 100644 ckanext/harvest/plugin/pylons_plugin.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7920a59d..e94c0777a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: python-version: '3.8' - name: Install requirements @@ -19,7 +19,7 @@ jobs: needs: lint strategy: matrix: - ckan-version: ["2.10", 2.9, 2.9-py2, 2.8, 2.7] + ckan-version: ["2.10", 2.9] fail-fast: false name: CKAN ${{ matrix.ckan-version }} @@ -55,14 +55,8 @@ jobs: # Replace default path to CKAN core config file with the one on the container sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini - name: Setup extension (CKAN >= 2.9) - if: ${{ matrix.ckan-version != '2.7' && matrix.ckan-version != '2.8' }} run: | ckan -c test.ini db init ckan -c test.ini harvester initdb - - name: Setup extension (CKAN < 2.9) - if: ${{ matrix.ckan-version == '2.7' || matrix.ckan-version == '2.8' }} - run: | - paster --plugin=ckan db init -c test.ini - paster --plugin=ckanext-harvest harvester initdb -c test.ini - name: Run tests run: pytest --ckan-ini=test.ini --cov=ckanext.harvest --disable-warnings ckanext/harvest/tests diff --git a/ckanext/harvest/harvesters/base.py b/ckanext/harvest/harvesters/base.py index c3dd8605f..746d7271e 100644 --- a/ckanext/harvest/harvesters/base.py +++ b/ckanext/harvest/harvesters/base.py @@ -16,7 +16,7 @@ from ckan.logic.schema import default_create_package_schema from ckan.lib.navl.validators import ignore_missing, ignore -from ckan.lib.munge import munge_title_to_name, substitute_ascii_equivalents +from ckan.lib.munge import munge_title_to_name, munge_tag from ckanext.harvest.model import (HarvestObject, HarvestGatherError, HarvestObjectError, HarvestJob) @@ -25,25 +25,6 @@ from ckanext.harvest.interfaces import IHarvester from ckanext.harvest.logic.schema import unicode_safe -if p.toolkit.check_ckan_version(min_version='2.3'): - from ckan.lib.munge import munge_tag -else: - # Fallback munge_tag for older ckan versions which don't have a decent - # munger - def _munge_to_length(string, min_length, max_length): - '''Pad/truncates a string''' - if len(string) < min_length: - string += '_' * (min_length - len(string)) - if len(string) > max_length: - string = string[:max_length] - return string - - def munge_tag(tag): - tag = substitute_ascii_equivalents(tag) - tag = tag.lower().strip() - tag = re.sub(r'[^a-zA-Z0-9\- ]', '', tag).replace(' ', '-') - tag = _munge_to_length(tag, model.MIN_TAG_LENGTH, model.MAX_TAG_LENGTH) - return tag log = logging.getLogger(__name__) diff --git a/ckanext/harvest/plugin/__init__.py b/ckanext/harvest/plugin/__init__.py index a2a0b4f54..0843f7a43 100644 --- a/ckanext/harvest/plugin/__init__.py +++ b/ckanext/harvest/plugin/__init__.py @@ -13,11 +13,7 @@ import ckan.plugins as p from ckan.lib.plugins import DefaultDatasetForm -try: - from ckan.lib.plugins import DefaultTranslation -except ImportError: - class DefaultTranslation(): - pass +from ckan.lib.plugins import DefaultTranslation import ckanext.harvest from ckanext.harvest.model import setup as model_setup @@ -28,10 +24,7 @@ class DefaultTranslation(): DATASET_TYPE_NAME ) -if p.toolkit.check_ckan_version(min_version='2.9.0'): - from ckanext.harvest.plugin.flask_plugin import MixinPlugin -else: - from ckanext.harvest.plugin.pylons_plugin import MixinPlugin +from ckanext.harvest.plugin.flask_plugin import MixinPlugin log = getLogger(__name__) assert not log.disabled @@ -47,8 +40,7 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla p.implements(p.IPackageController, inherit=True) p.implements(p.ITemplateHelpers) p.implements(p.IFacets, inherit=True) - if p.toolkit.check_ckan_version(min_version='2.5.0'): - p.implements(p.ITranslation, inherit=True) + p.implements(p.ITranslation, inherit=True) startup = False @@ -274,13 +266,6 @@ def configure(self, config): self.startup = False def update_config(self, config): - if not p.toolkit.check_ckan_version(min_version='2.0'): - assert 0, 'CKAN before 2.0 not supported by ckanext-harvest - '\ - 'genshi templates not supported any more' - if p.toolkit.asbool(config.get('ckan.legacy_templates', False)): - log.warn('Old genshi templates not supported any more by ' - 'ckanext-harvest so you should set ckan.legacy_templates ' - 'option to True any more.') p.toolkit.add_template_directory(config, '../templates') p.toolkit.add_public_directory(config, '../public') p.toolkit.add_resource('../fanstatic_library', 'ckanext-harvest') diff --git a/ckanext/harvest/plugin/pylons_plugin.py b/ckanext/harvest/plugin/pylons_plugin.py deleted file mode 100644 index 5e6f0e676..000000000 --- a/ckanext/harvest/plugin/pylons_plugin.py +++ /dev/null @@ -1,88 +0,0 @@ -# -*- coding: utf-8 -*- - -import ckan.plugins as p -from ckanext.harvest.utils import DATASET_TYPE_NAME - - -class MixinPlugin(p.SingletonPlugin): - p.implements(p.IRoutes, inherit=True) - - # IRoutes - - def before_map(self, map): - - # Most of the routes are defined via the IDatasetForm interface - # (ie they are the ones for a package type) - controller = "ckanext.harvest.controllers.view:ViewController" - - map.connect( - "{0}_delete".format(DATASET_TYPE_NAME), - "/" + DATASET_TYPE_NAME + "/delete/:id", - controller=controller, - action="delete", - ) - map.connect( - "{0}_refresh".format(DATASET_TYPE_NAME), - "/" + DATASET_TYPE_NAME + "/refresh/:id", - controller=controller, - action="refresh", - ) - map.connect( - "{0}_admin".format(DATASET_TYPE_NAME), - "/" + DATASET_TYPE_NAME + "/admin/:id", - controller=controller, - action="admin", - ) - map.connect( - "{0}_about".format(DATASET_TYPE_NAME), - "/" + DATASET_TYPE_NAME + "/about/:id", - controller=controller, - action="about", - ) - map.connect( - "{0}_clear".format(DATASET_TYPE_NAME), - "/" + DATASET_TYPE_NAME + "/clear/:id", - controller=controller, - action="clear", - ) - - map.connect( - "harvest_job_list", - "/" + DATASET_TYPE_NAME + "/{source}/job", - controller=controller, - action="list_jobs", - ) - map.connect( - "harvest_job_show_last", - "/" + DATASET_TYPE_NAME + "/{source}/job/last", - controller=controller, - action="show_last_job", - ) - map.connect( - "harvest_job_show", - "/" + DATASET_TYPE_NAME + "/{source}/job/{id}", - controller=controller, - action="show_job", - ) - map.connect( - "harvest_job_abort", - "/" + DATASET_TYPE_NAME + "/{source}/job/{id}/abort", - controller=controller, - action="abort_job", - ) - - map.connect( - "harvest_object_show", - "/" + DATASET_TYPE_NAME + "/object/:id", - controller=controller, - action="show_object", - ) - map.connect( - "harvest_object_for_dataset_show", - "/dataset/harvest_object/:id", - controller=controller, - action="show_object", - ref_type="dataset", - ) - - return map From 7b391e6be9c3fd66be236b1cf02e8c1f8083507b Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 09:28:11 -0300 Subject: [PATCH 06/74] Re introduce plugin.py file --- .../harvest/{plugin/__init__.py => plugin.py} | 26 +++++++++++++------ ckanext/harvest/plugin/flask_plugin.py | 20 -------------- 2 files changed, 18 insertions(+), 28 deletions(-) rename ckanext/harvest/{plugin/__init__.py => plugin.py} (96%) delete mode 100644 ckanext/harvest/plugin/flask_plugin.py diff --git a/ckanext/harvest/plugin/__init__.py b/ckanext/harvest/plugin.py similarity index 96% rename from ckanext/harvest/plugin/__init__.py rename to ckanext/harvest/plugin.py index 0843f7a43..b4bf34425 100644 --- a/ckanext/harvest/plugin/__init__.py +++ b/ckanext/harvest/plugin.py @@ -16,6 +16,7 @@ from ckan.lib.plugins import DefaultTranslation import ckanext.harvest +from ckanext.harvest import cli, views from ckanext.harvest.model import setup as model_setup from ckanext.harvest.model import HarvestSource, HarvestJob, HarvestObject from ckanext.harvest.log import DBLogHandler @@ -24,14 +25,13 @@ DATASET_TYPE_NAME ) -from ckanext.harvest.plugin.flask_plugin import MixinPlugin - log = getLogger(__name__) assert not log.disabled -class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): - +class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): + p.implements(p.IClick) + p.implements(p.IBlueprint) p.implements(p.IConfigurable) p.implements(p.IConfigurer, inherit=True) p.implements(p.IActions) @@ -44,6 +44,16 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla startup = False + # IClick + + def get_commands(self): + return cli.get_commands() + + # IBlueprint + + def get_blueprint(self): + return views.get_blueprints() + # ITranslation def i18n_directory(self): u'''Change the directory of the .mo translation files''' @@ -266,10 +276,10 @@ def configure(self, config): self.startup = False def update_config(self, config): - p.toolkit.add_template_directory(config, '../templates') - p.toolkit.add_public_directory(config, '../public') - p.toolkit.add_resource('../fanstatic_library', 'ckanext-harvest') - p.toolkit.add_resource('../public/ckanext/harvest/javascript', 'harvest-extra-field') + p.toolkit.add_template_directory(config, 'templates') + p.toolkit.add_public_directory(config, 'public') + 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') or {} diff --git a/ckanext/harvest/plugin/flask_plugin.py b/ckanext/harvest/plugin/flask_plugin.py deleted file mode 100644 index 7b8208aaa..000000000 --- a/ckanext/harvest/plugin/flask_plugin.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -import ckan.plugins as p -import ckanext.harvest.cli as cli -import ckanext.harvest.views as views - - -class MixinPlugin(p.SingletonPlugin): - p.implements(p.IClick) - p.implements(p.IBlueprint) - - # IClick - - def get_commands(self): - return cli.get_commands() - - # IBlueprint - - def get_blueprint(self): - return views.get_blueprints() From 8c340f3690ebb9f3f5af67d29751667962839f52 Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 10:24:17 -0300 Subject: [PATCH 07/74] Drop support for old versions in templates --- ckanext/harvest/templates/base.html | 5 +-- .../harvest_extra_field_resource.html | 1 - .../harvest/snippets/harvest_resource.html | 1 - .../harvest/templates/source/admin_base.html | 39 +++---------------- ckanext/harvest/templates/source/edit.html | 7 +--- ckanext/harvest/templates/source/new.html | 7 +--- .../templates/source/new_source_form.html | 8 ++-- .../harvest/templates/source/read_base.html | 16 ++------ ckanext/harvest/templates/source/search.html | 20 +--------- 9 files changed, 17 insertions(+), 87 deletions(-) delete mode 100644 ckanext/harvest/templates/harvest/snippets/harvest_extra_field_resource.html delete mode 100644 ckanext/harvest/templates/harvest/snippets/harvest_resource.html diff --git a/ckanext/harvest/templates/base.html b/ckanext/harvest/templates/base.html index 5a379a0b8..2fb8e0de8 100644 --- a/ckanext/harvest/templates/base.html +++ b/ckanext/harvest/templates/base.html @@ -2,8 +2,5 @@ {% block styles %} {{ super() }} - - {% set type = 'asset' if h.ckan_version().split('.')|map('int')|list >= [2, 9, 0] else 'resource' %} - {% include 'harvest/snippets/harvest_' ~ type ~ '.html' %} - + {% include 'harvest/snippets/harvest_asset.html' %} {% endblock %} diff --git a/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_resource.html b/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_resource.html deleted file mode 100644 index 9e8fda56d..000000000 --- a/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_resource.html +++ /dev/null @@ -1 +0,0 @@ -{% resource 'harvest-extra-field/main' %} diff --git a/ckanext/harvest/templates/harvest/snippets/harvest_resource.html b/ckanext/harvest/templates/harvest/snippets/harvest_resource.html deleted file mode 100644 index 69ce72363..000000000 --- a/ckanext/harvest/templates/harvest/snippets/harvest_resource.html +++ /dev/null @@ -1 +0,0 @@ -{% resource 'ckanext-harvest/styles/harvest.css' %} diff --git a/ckanext/harvest/templates/source/admin_base.html b/ckanext/harvest/templates/source/admin_base.html index ce65c99f0..f4b749304 100644 --- a/ckanext/harvest/templates/source/admin_base.html +++ b/ckanext/harvest/templates/source/admin_base.html @@ -7,65 +7,38 @@
  • {{ _('Admin') }}
  • {% endblock %} -{% block action_links %} +{% block content_action %} +
    {% if harvest_source.status and harvest_source.status.last_job and (harvest_source.status.last_job.status == 'New' or harvest_source.status.last_job.status == 'Running') %} Reharvest {% else %} {% set locale = h.dump_json({'content': _('This will re-run the harvesting for this source. Any updates at the source will overwrite the local datasets. Sources with a large number of datasets may take a significant amount of time to finish harvesting. Please confirm you would like us to start reharvesting.')}) %} - {{ _('Reharvest') }} - {% endif %} {% if harvest_source.status and harvest_source.status.last_job and (harvest_source.status.last_job.status == 'Running') %} - {{ _('Stop') }} - {% endif %} {% set locale = h.dump_json({'content': _('Warning: This will remove all datasets for this source, as well as all previous job reports. Are you sure you want to continue?')}) %} - {{ _('Clear') }} - - - {{ _('View harvest source') }} - - -{% endblock %} - -{# CKAN 2.0 #} -{% block actions_content %} - {{ self.action_links() }} -{% endblock %} - -{# CKAN 2.1 #} -{% block content_action %} -
    - {{ self.action_links() }} -
    +
    {% endblock %} {% block page_header_tabs %} - {% set ckan_version = h.ckan_version().split('.')[1] %} - {% if ckan_version | int >= 9 %} - {{ h.build_nav_icon('harvester.admin', _('Dashboard'), id=harvest_source.name, icon='dashboard') }} - {{ h.build_nav_icon('harvester.job_list', _('Jobs'), source=harvest_source.name, icon='reorder') }} - {{ h.build_nav_icon(c.dataset_type ~ '.edit', _('Edit'), id=harvest_source.name, icon='edit') }} - {% else %} - {{ h.build_nav_icon('{0}_admin'.format(c.dataset_type), _('Dashboard'), id=harvest_source.name, icon='dashboard') }} - {{ h.build_nav_icon('{0}_job_list'.format(c.dataset_type), _('Jobs'), source=harvest_source.name, icon='reorder') }} - {{ h.build_nav_icon('{0}_edit'.format(c.dataset_type), _('Edit'), id=harvest_source.name, icon='edit') }} - {% endif %} + {{ h.build_nav_icon('harvester.admin', _('Dashboard'), id=harvest_source.name, icon='dashboard') }} + {{ h.build_nav_icon('harvester.job_list', _('Jobs'), source=harvest_source.name, icon='reorder') }} + {{ h.build_nav_icon(c.dataset_type ~ '.edit', _('Edit'), id=harvest_source.name, icon='edit') }} {% endblock %} diff --git a/ckanext/harvest/templates/source/edit.html b/ckanext/harvest/templates/source/edit.html index 776bc8952..d739d1232 100644 --- a/ckanext/harvest/templates/source/edit.html +++ b/ckanext/harvest/templates/source/edit.html @@ -6,12 +6,7 @@
    {% block form %} - {% if c.form %} - {# CKAN < 2.3 #} - {{ c.form | safe }} - {% else %} - {{- h.snippet(form_snippet, c=c, **form_vars) -}} - {% endif %} + {{- h.snippet(form_snippet, c=c, **form_vars) -}} {% endblock %}
    {% endblock %} diff --git a/ckanext/harvest/templates/source/new.html b/ckanext/harvest/templates/source/new.html index fc03de3f4..b7feb3d9c 100644 --- a/ckanext/harvest/templates/source/new.html +++ b/ckanext/harvest/templates/source/new.html @@ -13,12 +13,7 @@ {% block primary_content %}
    - {% if c.form %} - {# CKAN < 2.3 #} - {{ c.form | safe }} - {% else %} - {{- h.snippet(form_snippet, c=c, **form_vars) -}} - {% endif %} + {{- h.snippet(form_snippet, c=c, **form_vars) -}}
    {% endblock %} diff --git a/ckanext/harvest/templates/source/new_source_form.html b/ckanext/harvest/templates/source/new_source_form.html index 015371655..8453b8ab2 100644 --- a/ckanext/harvest/templates/source/new_source_form.html +++ b/ckanext/harvest/templates/source/new_source_form.html @@ -1,10 +1,8 @@ {% import 'macros/form.html' as form %} +{% include 'harvest/snippets/harvest_extra_field_asset.html' %} -{% set type = 'asset' if h.ckan_version().split('.')|map('int')|list >= [2, 9, 0] else 'resource' %} -{% include 'harvest/snippets/harvest_extra_field_' ~ type ~ '.html' %} - -
    + {% block errors %}{{ form.errors(error_summary) }}{% endblock %} @@ -14,7 +12,7 @@ {% endcall %} -{{ h.csrf_input() if 'csrf_input' in h }} + {{ h.csrf_input() if 'csrf_input' in h }} {{ form.input('title', id='field-title', label=_('Title'), placeholder=_('eg. A descriptive title'), value=data.title, error=errors.title, classes=['control-full'], attrs={'data-module': 'slug-preview-target'}) }} diff --git a/ckanext/harvest/templates/source/read_base.html b/ckanext/harvest/templates/source/read_base.html index 984427456..3e21e6e61 100644 --- a/ckanext/harvest/templates/source/read_base.html +++ b/ckanext/harvest/templates/source/read_base.html @@ -6,16 +6,14 @@ {% endif %} {% endblock %} -{# CKAN 2.0 #} {% block actions_content %} {% if authorized_user %}
  • {{ self.admin_link() }}
  • {% endif %} {% endblock %} -{# TODO: once #354 is merged in CKAN core .profile-info doesn't exist #} {% block secondary_content %} -
    +

    {{ harvest_source.title }}

    {% if harvest_source.notes %} @@ -37,7 +35,7 @@

    {{ harvest_source.title }}

    {% endblock %} {% block primary_content %} -
    +
    {% block page_header %} diff --git a/ckanext/harvest/templates/source/search.html b/ckanext/harvest/templates/source/search.html index b7797b940..d1afcbf20 100644 --- a/ckanext/harvest/templates/source/search.html +++ b/ckanext/harvest/templates/source/search.html @@ -8,23 +8,7 @@ {% endblock %} -{% if g.ckan_base_version.startswith('2.0') %} - {# CKAN 2.0 #} - - {% block add_action_content %} - {{ h.snippet('snippets/add_source_button.html', dataset_type=c.dataset_type) }} - {% endblock %} -{% endif %} - {% block primary_content %} - {% if g.ckan_base_version.startswith('2.0') %} - {# CKAN 2.0 #} - - {% include 'source/search_2.0.html' %} - - {% else %} - {# > CKAN 2.0 #} -
    {% block page_primary_action %} @@ -56,9 +40,7 @@ {{ c.page.pager(q=c.q) }}
    - {% endif %} - -{% endblock %} + {% endblock %} From aa44587b7af9cac71e14f5adb56d2714cdb139bc Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 10:27:12 -0300 Subject: [PATCH 08/74] Remove old snippets for resource/asset compatibility --- ckanext/harvest/templates/base.html | 2 +- ckanext/harvest/templates/harvest/snippets/harvest_asset.html | 1 - .../templates/harvest/snippets/harvest_extra_field_asset.html | 1 - ckanext/harvest/templates/source/new_source_form.html | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 ckanext/harvest/templates/harvest/snippets/harvest_asset.html delete mode 100644 ckanext/harvest/templates/harvest/snippets/harvest_extra_field_asset.html diff --git a/ckanext/harvest/templates/base.html b/ckanext/harvest/templates/base.html index 2fb8e0de8..d1e58db2e 100644 --- a/ckanext/harvest/templates/base.html +++ b/ckanext/harvest/templates/base.html @@ -2,5 +2,5 @@ {% block styles %} {{ super() }} - {% include 'harvest/snippets/harvest_asset.html' %} + {% asset 'ckanext-harvest/harvest_css' %} {% endblock %} diff --git a/ckanext/harvest/templates/harvest/snippets/harvest_asset.html b/ckanext/harvest/templates/harvest/snippets/harvest_asset.html deleted file mode 100644 index b78146a15..000000000 --- a/ckanext/harvest/templates/harvest/snippets/harvest_asset.html +++ /dev/null @@ -1 +0,0 @@ -{% asset 'ckanext-harvest/harvest_css' %} diff --git a/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_asset.html b/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_asset.html deleted file mode 100644 index 47e8b8965..000000000 --- a/ckanext/harvest/templates/harvest/snippets/harvest_extra_field_asset.html +++ /dev/null @@ -1 +0,0 @@ -{% asset 'harvest-extra-field/main' %} diff --git a/ckanext/harvest/templates/source/new_source_form.html b/ckanext/harvest/templates/source/new_source_form.html index 8453b8ab2..c03aff042 100644 --- a/ckanext/harvest/templates/source/new_source_form.html +++ b/ckanext/harvest/templates/source/new_source_form.html @@ -1,6 +1,6 @@ {% import 'macros/form.html' as form %} -{% include 'harvest/snippets/harvest_extra_field_asset.html' %} +{% asset 'harvest-extra-field/main' %} From 163bb39e3a1e13270680588cbae1076769ab2548 Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 10:42:26 -0300 Subject: [PATCH 09/74] Drop admin link support for old versions --- ckanext/harvest/templates/source/read_base.html | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/ckanext/harvest/templates/source/read_base.html b/ckanext/harvest/templates/source/read_base.html index 3e21e6e61..1b03eb3a3 100644 --- a/ckanext/harvest/templates/source/read_base.html +++ b/ckanext/harvest/templates/source/read_base.html @@ -1,17 +1,5 @@ {% extends "source/base.html" %} -{% block admin_link %} - {% if h.check_access('harvest_source_update', {'id':harvest_source.id }) %} - {{ h.nav_link(_('Admin'), named_route='{0}_admin'.format(c.dataset_type), id=harvest_source.name, class_='btn btn-primary', icon='wrench')}} - {% endif %} -{% endblock %} - -{% block actions_content %} - {% if authorized_user %} -
  • {{ self.admin_link() }}
  • - {% endif %} -{% endblock %} - {% block secondary_content %}
    @@ -40,7 +28,9 @@

    {{ harvest_source.title }}