Add custom harvest source read page (provisional)

This commit is contained in:
amercader 2012-12-05 15:47:02 +00:00
parent 2dba7fbf78
commit 697933f8d0
2 changed files with 109 additions and 148 deletions

View File

@ -55,6 +55,9 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
def search_template(self): def search_template(self):
return 'source/search.html' return 'source/search.html'
def read_template(self):
return 'source/read.html'
def new_template(self): def new_template(self):
return 'source/new.html' return 'source/new.html'

View File

@ -1,160 +1,118 @@
{% extends "page.html" %} {% extends "page.html" %}
{% block title %}{{ _('Harvest Source Details') }} - {{ super() }}{% endblock %} {% set pkg = c.pkg_dict %}
{% block styles %}
{{ super() }}
<link type="text/css" rel="stylesheet" media="all" href="/ckanext/harvest/style.css" />
{% endblock %}
{% block subtitle %}{{ pkg.title or pkg.name }}{% endblock %}
{% block breadcrumb_content %} {% block breadcrumb_content %}
<li>{{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}</li>
<li class="active">{{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}</li>
{% endblock %} {% endblock %}
{% block primary %} {% block actions_content %}
<article class="module"> {% if h.check_access('package_update', {'id':pkg.id }) %}
<div class="module-content"> <li>{{ h.nav_named_link(_('Edit'), '{0}_edit'.format(c.dataset_type), id=c.harvest_source.name, class_='btn btn-primary', icon='wrench')}}</li>
<div class="harvest-content">
{% if c.source %}
<h1>Harvest Source Details</h1>
<div id="harvest-source-actions">
<img src="/ckanext/harvest/images/icons/source_edit.png" alt="Edit" /><a href="/harvest/edit/{{ c.source.id }}">Edit source</a> |
<img src="/ckanext/harvest/images/icons/source_refresh.png" alt="Refresh" /><a href="/harvest/refresh/{{ c.source.id }}">Refresh source</a> |
<a href="/harvest">Sources list</a>
</div>
{% if not c.source.active %}
<div class="alert alert-block">NB: This Harvest Source is Withdrawn. Therefore the Gemini XML will not be harvested again. However, any metadata that was previously harvested, remains in the catalogue.</div>
{% endif %} {% endif %}
<table id="harvest-source-details" class="table table-bordered table-condensed"> <li>{{ h.follow_button('dataset', pkg.id) }}</li>
<tr> {% endblock %}
<th>ID</th>
<td>{{ c.source.id }}</td> {% block primary_content %}
</tr> {% block package_revision_info %}
<tr> {% if c.pkg_revision_id %}
<th>URL</th> <div class="module info">
<td>{{ c.source.url }}</td> <p class="module-content">
</tr> {% set timestamp = h.render_datetime(c.pkg_revision_timestamp, with_hours=True) %}
<tr> {% set url = h.url(controller='package', action='read', id=pkg.name) %}
<th>Type</th>
<td>{{ c.source.type }}</td> {% if c.pkg_revision_not_latest %}
</tr> {% trans timestamp=timestamp, url=url %}This is an old revision of this dataset, as edited at {{ timestamp }}. It may differ significantly from the <a href="{{ url }}">current revision</a>.{% endtrans %}
<tr>
<th>Withdrawn</th>
<td>{{ not c.source.active }}</td>
</tr>
{% if c.source.title %}
<tr>
<th>Title</th>
<td>{{ c.source.title }}</td>
</tr>
{% endif %}
<tr>
<th>Description</th>
<td>{{ c.source.description }}</td>
</tr>
<tr>
<th>Configuration</th>
{% if c.source.config %}
<td>{{ c.source.config }}</td>
{% else %} {% else %}
<td>-</td> {% trans timestamp=timestamp %}This is the current revision of this dataset, as edited at {{ timestamp }}.{% endtrans %}
{% endif %} {% endif %}
</tr> </div>
{% if c.publisher_auth %} </div>
<tr>
<th>User</th>
<td>{{ c.source.user_id }}</td>
</tr>
{% endif %} {% endif %}
{% if c.publisher_auth %} {% endblock %}
<tr>
<th>Publisher</th> <article class="module prose">
{% if c.source.publisher_title %}
<td>${c.source.publisher_title}</td> {% block package_header %}
{% endif %} <header class="module-content page-header">
{% if not c.source.publisher_title %} <ul class="nav nav-tabs">
<td>{{ c.source.publisher_id }}</td> <li{% if c.action == 'read' %} class="active"{% endif %}>
{% endif %} {% link_for _('Dataset'), controller='package', action='read', id=pkg.name, icon='sitemap' %}
</tr>
{% endif %}
<tr>
<th>Created</th>
<td>{{ c.source.created }}</td>
</tr>
<tr>
<th>Total jobs</th>
<td>{{ c.source.status.job_count }}</td>
</tr>
<tr>
<th>Status</th>
<td>
<a name="errors"></a>Last Harvest Errors: {{ c.source.status.last_harvest_statistics.errors }}<br/>
{% if c.source.status.last_harvest_errors.gather | length > 0 %}
<i>Gathering errors</i>
<ul>
{% for error in c.source.status.last_harvest_errors.gather %}
<li>
{% set lines = error.split('\n') %}
{% for line in lines %}
<div>{{ line }}</div>
{% endfor %}
</li> </li>
{% endfor %} <li{% if c.action == 'activity' %} class="active"{% endif %}>
</ul> {% link_for _('Activity Stream'), controller='package', action='activity', id=pkg.name, icon='time' %}
{% endif %} </li>
<li{% if c.action == 'followers' %} class="active"{% endif %}>
{% if c.source.status.last_harvest_errors.object | length > 0 %} {% link_for _('Followers'), controller='package', action='followers', id=pkg.name, icon='group' %}
<i>Object errors</i> </li>
<ul> <li{% if c.action == 'related' %} class="active"{% endif %}>
{% for error in c.source.status.last_harvest_errors.object %} {% link_for _('Related'), controller='related', action='list', id=pkg.name, icon='picture' %}
<li>
<div>GUID <a href="{{g.site_url}}/harvest/object/{{error.object_id}}">{{error.object_guid}}</a></div>
{% set lines = error['message'].split('\n') %}
{% for line in lines %}
<div>{{ line }}</div>
{% endfor %}
</li> </li>
{% endfor %}
</ul> </ul>
</header>
{% endblock %}
{% block package_content %}
{% block package_description %}
<section class="module-content">
<div style="color:red; font-weight:bold">CUSTOM HARVEST SOURCE TEMPLATE for {{ c.dataset_type}}</div>
</section>
<section class="module-content">
<h1>{{ pkg.title or pkg.name }}
{% if pkg.state.startswith('draft') %}
[{{ _('Draft') }}]
{% endif %} {% endif %}
</h1>
Last Harvest Added: {{ c.source.status.last_harvest_statistics.added }}<br/> {% if c.pkg_notes_formatted %}
Last Harvest Updated: {{ c.source.status.last_harvest_statistics.updated }}<br/> <div class="notes embedded-content">
Last Harvest: {{ c.source.status.last_harvest_request }} <br/> {{ c.pkg_notes_formatted }}
Next Harvest: {{ c.source.status.next_harvest }}
</td>
</tr>
<tr>
<th>Total Errors</th>
<td>{{ c.source.status.overall_statistics.errors }}</td>
</tr>
<tr>
<th>Total Datasets</th>
<td>{{ c.source.status.overall_statistics.added }}</td>
</tr>
<tr>
<th>Datasets</th>
<td>
<a name="datasets"></a>
<div>There could be a 10 minutes delay before these datasets (or changes to them) appear on
the site or on search results.</div>
<p>There are <strong>{{ c.page.item_count }}</strong> datasets.</p>
{{ c.page.pager() }}
{% for item in c.page.items %}
<div>
<a href="/dataset/{{ item }}">{{ item }}</a>
</div> </div>
{% endfor %}
{{ c.page.pager() }}
</td>
</tr>
</table>
{% endif %} {% endif %}
</div> <span class="insert-comment-thread"></span>
</div> </section>
{% endblock %}
{% block package_resources %}
{% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %}
{% endblock %}
{% block package_tags %}
{% snippet "package/snippets/tags.html", tags=pkg.tags %}
{% endblock %}
{% block package_additional_info %}
{% snippet "package/snippets/additional_info.html", pkg_dict=pkg %}
{% endblock %}
{% endblock %}
</article> </article>
{% endblock %} {% endblock %}
{% block sidebar %}{% endblock %} {% block secondary_content %}
{% block secondary_help_content %}{% endblock %}
{% block package_groups %}
{% for group in pkg.groups %}
{% snippet "snippets/group.html", group=group, truncate=70 %}
{% endfor %}
{% endblock %}
{% block package_social %}
{% snippet "snippets/social.html" %}
{% endblock %}
{% block package_related %}
{% snippet "snippets/related.html", item=c.pkg.related|last, pkg_name=pkg.name %}
{% endblock %}
{% block package_license %}
{% snippet "snippets/license.html", pkg_dict=pkg %}
{% endblock %}
{% endblock %}