Skip to content

Commit

Permalink
Merge branch '2.9-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 25, 2018
2 parents fa0e277 + dea0bd0 commit 7d1bcdf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 228 deletions.
201 changes: 0 additions & 201 deletions ckanext/harvest/controllers/organization.py

This file was deleted.

4 changes: 3 additions & 1 deletion ckanext/harvest/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

from pylons import request
from ckan import logic
from ckan import model
import ckan.lib.helpers as h
Expand All @@ -9,6 +8,9 @@
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
Expand Down
23 changes: 16 additions & 7 deletions ckanext/harvest/plugin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -175,12 +176,11 @@ def edit_template(self):
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
Expand Down Expand Up @@ -245,9 +245,6 @@ def before_map(self, map):
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')

org_controller = 'ckanext.harvest.controllers.organization:OrganizationController'
map.connect('{0}_org_list'.format(DATASET_TYPE_NAME), '/organization/' + DATASET_TYPE_NAME + '/' + '{id}', controller=org_controller, action='source_list')

return map

def update_config(self, config):
Expand All @@ -263,6 +260,18 @@ def update_config(self, config):
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):
Expand Down
21 changes: 10 additions & 11 deletions ckanext/harvest/templates/source/admin_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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') %}
{{ '<li>' if show_li }}<a class="btn disabled" rel="tooltip" title="There already is an unrun job for this source"><i class="fa fa-lg fa-refresh icon-refresh icon-large"></i> Reharvest</a>{{ '</li>' if show_li }}
<a class="btn disabled" rel="tooltip" title="There already is an unrun job for this source"><i class="fa fa-lg fa-refresh icon-refresh icon-large"></i> Reharvest</a>
{% 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.')}) %}
{{ '<li>' if show_li }}

<a href="{{ h.url_for('harvest_refresh', id=source.id) }}" class="btn btn-default" data-module="confirm-action" data-module-i18n="{{ locale }}"
title="{{ _('Start a new harvesting job for this harvest source now') }}">
<i class="fa fa-refresh icon-refresh"></i>
{{ _('Reharvest') }}
</a>
{{ '</li>' if show_li }}

{% endif %}
{% if source.status and source.status.last_job and (source.status.last_job.status == 'Running') %}
{{ '<li>' if show_li }}

<a href="{{ h.url_for('harvest_job_abort', source=source.name, id=source.status.last_job.id) }}" class="btn btn-default" title="Stop this Job">
<i class="fa fa-ban icon-ban-circle"></i>
{{ _('Stop') }}
</a>
{{ '</li>' if show_li }}

{% 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?')}) %}
{{ '<li>' if show_li }}

<a href="{{ h.url_for('harvest_clear', id=source.id) }}" class="btn btn-default" data-module="confirm-action" data-module-i18n="{{ locale }}"
title="{{ _('Delete all harvest jobs and existing datasets from this source') }}">
{{ _('Clear') }}
</a>
{{ '</li>' if show_li }}

{{ '<li>' if show_li }}


<a href="{{ h.url_for('{0}_read'.format(c.dataset_type), id=source.id) }}" class="btn btn-default">
<i class="fa fa-eye eye-open"></i>
{{ _('View harvest source') }}
</a>
{{ '</li>' if show_li }}


{% endblock %}

{# CKAN 2.0 #}
Expand Down
13 changes: 5 additions & 8 deletions ckanext/harvest/templates/source/read_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ <h1 class="heading">{{ c.harvest_source.title }}</h1>
<article class="module prose">
{% block page_header %}
<header class="module-content page-header">
{# CKAN 2.1+ #}
{% if authorized_user and not c.__version__.startswith('2.0') %}
{% block content_action %}
<div class="content_action">
{{ self.admin_link() }}
</div>
{% endblock %}
{% endif %}
{% block content_action %}
<div class="content_action">
{{ self.admin_link() }}
</div>
{% endblock %}
<ul class="nav nav-tabs">
{% block page_header_tabs %}
{{ h.build_nav_icon('{0}_read'.format(c.dataset_type), _('Datasets'), id=source.name, icon='sitemap') }}
Expand Down

0 comments on commit 7d1bcdf

Please sign in to comment.