Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADX-998 [3rd-party] Update ckanext-harvest to latest version #110

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% if harvest_source.source_type == 'dhis2-pivot-tables' %}
{% set harvest_refresh_url = h.url_for('dhis2_harvester.pivot_tables_refresh', harvest_source_id=harvest_source.name) %}
{% else %}
{% set harvest_refresh_url = h.url_for('harvest_refresh', id=harvest_source.name) %}
{% set harvest_refresh_url = h.url_for('harvest.refresh', id=harvest_source.name) %}
{% endif %}
<a href="{{ harvest_refresh_url }}" class="btn btn-default" data-module="confirm-action" data-module-i18n="{{ locale }}"
title="{{ _('Start a new import job for this DHIS2 source now') }}">
Expand Down
12 changes: 6 additions & 6 deletions ckanext/dhis2harvester/templates/source/admin_base.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% ckan_extends %}

{% block page_header_tabs %}
{{ h.build_nav_icon('harvest_admin', _('Dashboard'), id=harvest_source.name, icon='dashboard') }}
{{ h.build_nav_icon('harvest_job_list', _('Jobs'), source=harvest_source.name, icon='reorder') }}
{{ 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') }}
{% if harvest_source.source_type == 'dhis2-pivot-tables' %}
<li>
<a href="{{ h.url_for('dhis2_harvester.pivot_tables_edit', harvest_source_id=harvest_source.id) }}">
Expand All @@ -11,28 +11,28 @@
</a>
</li>
{% else %}
{{ h.build_nav_icon('harvest_edit', _('Edit'), id=harvest_source.name, icon='edit') }}
{{ h.build_nav_icon('harvest.edit', _('Edit'), id=harvest_source.name, icon='edit') }}
{% endif %}
{% endblock %}

{% block action_links %}
{% snippet 'snippets/harvest_run_action.html', harvest_source=harvest_source %}
{% if harvest_source.status and harvest_source.status.last_job and (harvest_source.status.last_job.status == 'Running') %}

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

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

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

<a href="{{ h.url_for('harvest_read', id=harvest_source.name) }}" class="btn btn-default">
<a href="{{ h.url_for('harvest.read', id=harvest_source.name) }}" class="btn btn-default">
<i class="fa fa-eye eye-open"></i>
{{ _('View DHIS2 source') }}
</a>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/dhis2harvester/templates/source/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<li>{{ h.nav_link(_('Organizations'), named_route='organizations_index') }}</li>
<li>{{ h.nav_link(org.title or org.name|truncate(10), named_route='organization_read', id=org.name) }}</li>
<li>{{ h.nav_link(_('DHIS2 Sources'), named_route='harvest_search', organization=org.name) }}</li>
<li{{ self.breadcrumb_content_root_selected() }}>{{ h.nav_link(harvest_source.title|truncate(10), named_route='harvest_read', id=harvest_source.name) }}</li>
<li{{ self.breadcrumb_content_root_selected() }}>{{ h.nav_link(harvest_source.title|truncate(10), named_route='harvest.read', id=harvest_source.name) }}</li>
{% else %}
<li>{{ h.nav_link(_('DHIS2 Sources'), named_route='harvest_search') }}</li>
<li{{ self.breadcrumb_content_root_selected() }}>{{ h.nav_link(harvest_source.title|truncate(30), named_route='harvest_read', id=harvest_source.name) }}</li>
<li{{ self.breadcrumb_content_root_selected() }}>{{ h.nav_link(harvest_source.title|truncate(30), named_route='harvest.read', id=harvest_source.name) }}</li>
{% endif %}
{% endblock %}
12 changes: 6 additions & 6 deletions ckanext/dhis2harvester/templates/source/pivot_table_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
{% set org = g.owner_org %}
<li>{{ h.nav_link(_('Organizations'), controller='organization', action='index') }}</li>
<li>{{ h.nav_link(org.title or org.name|truncate(10), controller='organization', action='read', id=org.name) }}</li>
<li><a href="{{ h.url_for('harvest_search', organization=org.name)}}">{{_('DHIS2 Sources')}}</a></li>
<li><a href="{{ h.url_for('harvest_read', id=harvest_source.name) }}">{{ harvest_source.title|truncate(15) }}</a></li>
<li><a href="{{ h.url_for('harvest.search', organization=org.name)}}">{{_('DHIS2 Sources')}}</a></li>
<li><a href="{{ h.url_for('harvest.read', id=harvest_source.name) }}">{{ harvest_source.title|truncate(15) }}</a></li>
<li{{ self.breadcrumb_content_root_selected() }}>
<a href="{{ h.url_for('harvest_admin', id=harvest_source.name) }}">Admin</a>
<a href="{{ h.url_for('harvester.admin', id=harvest_source.name) }}">Admin</a>
</li>
{% else %}
<li><a href="{{ h.url_for('harvest_search')}}">{{_('DHIS2 Sources')}}</a></li>
<li><a href="{{ h.url_for('harvest.search')}}">{{_('DHIS2 Sources')}}</a></li>
<li class="active">
<a href="{{ h.url_for('dhis2_harvester.pivot_tables_new') }}">{{ _('Create DHIS2 Pivot Table Fetcher') }}</a>
</li>
Expand All @@ -30,12 +30,12 @@

{% block page_header_tabs %}
<li>
<a href="{{ h.url_for('harvest_admin', id=harvest_source.name) }}">
<a href="{{ h.url_for('harvester.admin', id=harvest_source.name) }}">
<i class="fa fa-dashboard"></i> {{ _('Dashboard') }}
</a>
</li>
<li>
<a href="{{ h.url_for('harvest_job_list', source=harvest_source.name) }}">
<a href="{{ h.url_for('harvester.job_list', source=harvest_source.name) }}">
<i class="fa fa-reorder"></i> {{ _('Jobs') }}
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h1>{{_('Finalise DHIS2 Source')}}</h1>
{{ 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', 'class': 'form-control'}) }}

{% set prefix = 'harvest' %}
{% set domain = h.url_for('harvest_read', id='', qualified=true) %}
{% set domain = h.url_for('harvest.read', id='', qualified=true) %}
{% set domain = domain|replace("http://", "")|replace("https://", "") %}
{% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<harvest-source>'} %}

Expand Down
6 changes: 6 additions & 0 deletions ckanext/dhis2harvester/templates/source/read_base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% ckan_extends %}
{#{% set authorized_user = h.check_access('harvest_source_update', {'id': harvest_source.id}) %}#}

{% block admin_link %}
{% if h.check_access('harvest_source_update', {'id':harvest_source.name }) %}
{{ h.nav_link(_('Admin'), named_route='harvester.admin', id=harvest_source.name, class_='btn btn-primary', icon='wrench')}}
{% endif %}
{% endblock %}

{% block content_action %}
<div class="content_action btn-group">
{% if authorized_user %}
Expand Down
14 changes: 7 additions & 7 deletions ckanext/dhis2harvester/ui_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def pivot_tables_refresh(harvest_source_id):
log.error("An error occurred: {}".format(str(e)))
raise e
_flash_source_refresh_success()
return h.redirect_to('harvest_admin', id=harvester_name)
return h.redirect_to('harvester.admin', id=harvester_name)
else:
data = {}
(dhis2_url, dhis2_api_version, dhis2_auth_token) = __get_dhis2_connection_details_from_harvest_source(
Expand All @@ -124,7 +124,7 @@ def pivot_tables_refresh(harvest_source_id):
try:
harvest_utils.create_job(harvest_source_id)
_flash_source_refresh_success()
return h.redirect_to('harvest_admin', id=harvester_name)
return h.redirect_to('harvester.admin', id=harvester_name)
except ValidationError as e:
log.error("An error occurred: {}".format(str(e)))
data['dhis2_url'] = dhis2_url
Expand Down Expand Up @@ -244,7 +244,7 @@ def __save_harvest_source(data):
raise e
log.info("Harvest source {} created".format(harvester_name))

return h.redirect_to('harvest_admin', id=harvester_name)
return h.redirect_to('harvester.admin', id=harvester_name)


def __update_harvest_source(data):
Expand All @@ -254,7 +254,7 @@ def __update_harvest_source(data):
except ValidationError as e:
log.error("An error occurred: {}".format(str(e.error_dict)))
raise e
return h.redirect_to('harvest_admin', id=harvester_name)
return h.redirect_to('harvester.admin', id=harvester_name)


def __save_or_update_harvest_source(data, harvest_source=None):
Expand All @@ -271,7 +271,7 @@ def __save_or_update_harvest_source(data, harvest_source=None):
else:
data['area_id_map_owner'] = current_user.name
except Exception as e:
errors = {"area_id_map_url": [_("Failed to download the area id map csv file."), e.message]}
errors = {"area_id_map_url": [_("Failed to download the area id map csv file."), e]}
return __summary_stage(data, errors, harvest_source=harvest_source)
try:
csv_stream = StringIO(area_csv.text)
Expand All @@ -286,8 +286,8 @@ def __save_or_update_harvest_source(data, harvest_source=None):
else:
return __save_harvest_source(data)
except Exception as e:
log.exception(e.message)
h.flash_error('Error while saving the harvest source: {}'.format(e.message))
log.exception(e)
h.flash_error('Error while saving the harvest source: {}'.format(e))
return __summary_stage(data, harvest_source=harvest_source)


Expand Down