[#58] Fixes to make harvest templates to work with both CKAN 2.0 and 2.1

This commit is contained in:
John Martin 2013-08-15 16:45:02 +01:00
parent 1c36b33aaf
commit 575df637b4
4 changed files with 61 additions and 8 deletions

View File

@ -0,0 +1,8 @@
{% ckan_extends %}
{% if type == 'harvest' %}
{% set text_query = ungettext('{number} harvest source found for "{query}"', '{number} harvest sources found for "{query}"', count) %}
{% set text_query_none = _('Sorry no harvest sources found for "{query}"') %}
{% set text_no_query = ungettext('{number} harvest source found', '{number} harvest sources found', count) %}
{% set text_no_query_none = _('Sorry no harvest sources found') %}
{%- endif -%}

View File

@ -7,30 +7,42 @@
<li class="active"><a href="">{{ _('Admin') }}</a></li> <li class="active"><a href="">{{ _('Admin') }}</a></li>
{% endblock %} {% endblock %}
{% block actions_content %} {% block action_links %}
{% set show_li = c.__version == '2.0' %}
{% if source.status.last_job and (source.status.last_job.status == 'New' or source.status.last_job.status == 'Running') %} {% if source.status.last_job and (source.status.last_job.status == 'New' or source.status.last_job.status == 'Running') %}
<li><a class="btn disabled" rel="tooltip" title="There already is an unrun job for this source"><i class="icon-refresh icon-large"></i> Reharvest</a></li> {{ '<li>' if show_li }}<a class="btn disabled" rel="tooltip" title="There already is an unrun job for this source"><i class="icon-refresh icon-large"></i> Reharvest</a>{{ '</li>' if show_li }}
{% else %} {% 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.')}) %} {% 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> {{ '<li>' if show_li }}
<a href="{{ h.url_for('harvest_refresh', id=source.id) }}" class="btn" data-module="confirm-action" data-module-i18n="{{ locale }}" <a href="{{ h.url_for('harvest_refresh', id=source.id) }}" class="btn" data-module="confirm-action" data-module-i18n="{{ locale }}"
title="{{ _('Start a new harvesting job for this harvest source now') }}"> title="{{ _('Start a new harvesting job for this harvest source now') }}">
<i class="icon-refresh"></i> <i class="icon-refresh"></i>
{{ _('Reharvest') }} {{ _('Reharvest') }}
</a> </a>
</li> {{ '</li>' if show_li }}
{% endif %} {% 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?')}) %} {% 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> {{ '<li>' if show_li }}
<a href="{{ h.url_for('harvest_clear', id=source.id) }}" class="btn" data-module="confirm-action" data-module-i18n="{{ locale }}" <a href="{{ h.url_for('harvest_clear', id=source.id) }}" class="btn" data-module="confirm-action" data-module-i18n="{{ locale }}"
title="{{ _('Delete all harvest jobs and existing datasets from this source') }}"> title="{{ _('Delete all harvest jobs and existing datasets from this source') }}">
{{ _('Clear') }} {{ _('Clear') }}
</a> </a>
</li> {{ '</li>' if show_li }}
<li>{{ h.nav_named_link(_('View harvest source'), '{0}_read'.format(c.dataset_type), id=source.name, class_='btn', icon='eye-open')}}</li> {{ '<li>' if show_li }}{{ h.nav_named_link(_('View harvest source'), '{0}_read'.format(c.dataset_type), id=source.name, class_='btn', icon='eye-open')}}{{ '</li>' if show_li }}
{% endblock %} {% endblock %}
{# CKAN 2.0 #}
{% block actions_content %}
{{ self.action_links() }}
{% endblock %}
{# CKAN 2.1 #}
{% block content_action %}
<div class="content_action btn-group">
{{ self.action_links() }}
</div>
{% endblock %}
{% block page_header_tabs %} {% block page_header_tabs %}
{{ h.build_nav_icon('{0}_admin'.format(c.dataset_type), _('Dashboard'), id=source.name, icon='dashboard') }} {{ h.build_nav_icon('{0}_admin'.format(c.dataset_type), _('Dashboard'), id=source.name, icon='dashboard') }}

View File

@ -1,8 +1,13 @@
{% extends "source/base.html" %} {% extends "source/base.html" %}
{% block admin_link %}
{{ h.nav_named_link(_('Admin'), '{0}_admin'.format(c.dataset_type), id=c.harvest_source.name, class_='btn btn-primary', icon='wrench')}}
{% endblock %}
{# CKAN 2.0 #}
{% block actions_content %} {% block actions_content %}
{% if authorized_user %} {% if authorized_user %}
<li>{{ h.nav_named_link(_('Admin'), '{0}_admin'.format(c.dataset_type), id=c.harvest_source.name, class_='btn btn-primary', icon='wrench')}}</li> <li>{{ self.admin_link() }}</li>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@ -33,6 +38,14 @@
<article class="module prose"> <article class="module prose">
{% block page_header %} {% block page_header %}
<header class="module-content page-header"> <header class="module-content page-header">
{# CKAN 2.1+ #}
{% if authorized_user and c.__version__ != '2.0' %}
{% block content_action %}
<div class="content_action">
{{ self.admin_link() }}
</div>
{% endblock %}
{% endif %}
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{% block page_header_tabs %} {% block page_header_tabs %}
{{ h.build_nav_icon('{0}_read'.format(c.dataset_type), _('Datasets'), id=source.name, icon='sitemap') }} {{ h.build_nav_icon('{0}_read'.format(c.dataset_type), _('Datasets'), id=source.name, icon='sitemap') }}

View File

@ -16,6 +16,7 @@
{% block primary_content %} {% block primary_content %}
<section class="module"> <section class="module">
<div class="module-content"> <div class="module-content">
{% if c.__version__ == '2.0' %}
<form id="dataset-search" class="dataset-search clearfix" method="get" data-module="select-switch"> <form id="dataset-search" class="dataset-search clearfix" method="get" data-module="select-switch">
<span class="control-group search-giant"> <span class="control-group search-giant">
<input type="text" class="search" name="q" value="{{ c.q }}" autocomplete="off" placeholder="{{ _('Search...') }}" /> <input type="text" class="search" name="q" value="{{ c.q }}" autocomplete="off" placeholder="{{ _('Search...') }}" />
@ -71,6 +72,25 @@
{% endtrans %} {% endtrans %}
{% endif %} {% endif %}
{% else %}
{% set facets = {
'fields': c.fields_grouped,
'search': c.search_facets,
'titles': c.facet_titles,
'translated_fields': c.translated_fields,
'remove_field': c.remove_field }
%}
{% set sorting = [
(_('Relevance'), 'score desc, metadata_modified desc'),
(_('Name Ascending'), 'title_string asc'),
(_('Name Descending'), 'title_string desc'),
(_('Last Modified'), 'metadata_modified desc'),
(_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ]
%}
{% snippet 'snippets/search_form.html', type='harvest', query=c.q, sorting=sorting, sorting_selected=c.sort_by_selected, count=c.page.item_count, facets=facets, show_empty=request.params, error=c.query_error, placeholder=_("Search harvest sources...") %}
{% endif %}
{{ h.snippet('snippets/source_list.html', sources=c.page.items, show_organization=true) }} {{ h.snippet('snippets/source_list.html', sources=c.page.items, show_organization=true) }}
</div> </div>