[#5] Add job listing page
This commit is contained in:
parent
22389fc52a
commit
8576ad6784
|
@ -334,6 +334,24 @@ class ViewController(BaseController):
|
||||||
is_last=True)
|
is_last=True)
|
||||||
|
|
||||||
|
|
||||||
|
def list_jobs(self, source):
|
||||||
|
|
||||||
|
try:
|
||||||
|
context = {'model':model, 'user':c.user}
|
||||||
|
c.harvest_source = get_action('harvest_source_show')(context, {'id': source})
|
||||||
|
c.jobs = get_action('harvest_job_list')(context, {'source_id': c.harvest_source['id']})
|
||||||
|
|
||||||
|
return render('job/list.html')
|
||||||
|
|
||||||
|
except NotFound:
|
||||||
|
abort(404,_('Harvest source not found'))
|
||||||
|
except NotAuthorized,e:
|
||||||
|
abort(401,self.not_auth_message)
|
||||||
|
except Exception, e:
|
||||||
|
msg = 'An error occurred: [%s]' % str(e)
|
||||||
|
abort(500,msg)
|
||||||
|
|
||||||
|
|
||||||
def _make_autoform_items(self, harvesters_info):
|
def _make_autoform_items(self, harvesters_info):
|
||||||
states = [{'text': 'active', 'value': 'True'},
|
states = [{'text': 'active', 'value': 'True'},
|
||||||
{'text': 'withdrawn', 'value': 'False'},]
|
{'text': 'withdrawn', 'value': 'False'},]
|
||||||
|
|
|
@ -212,6 +212,8 @@ def harvest_job_list(context,data_dict):
|
||||||
if status:
|
if status:
|
||||||
query = query.filter(HarvestJob.status==status)
|
query = query.filter(HarvestJob.status==status)
|
||||||
|
|
||||||
|
query = query.order_by(HarvestJob.created.desc())
|
||||||
|
|
||||||
jobs = query.all()
|
jobs = query.all()
|
||||||
|
|
||||||
return [harvest_job_dictize(job,context) for job in jobs]
|
return [harvest_job_dictize(job,context) for job in jobs]
|
||||||
|
|
|
@ -216,6 +216,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
||||||
|
|
||||||
map.connect('harvest_object_show', '/harvest/object/:id', controller=controller, action='show_object')
|
map.connect('harvest_object_show', '/harvest/object/:id', controller=controller, action='show_object')
|
||||||
|
|
||||||
|
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_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_show', '/' + DATASET_TYPE_NAME + '/{source}/job/{id}', controller=controller, action='show_job')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
{% extends "page.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}{{ _('Harvest Jobs')}}{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumb_content %}
|
||||||
|
<li>{{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}</li>
|
||||||
|
<li>{{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}</li>
|
||||||
|
<li class="active">{{ h.nav_link(_('Jobs'), controller='ckanext.harvest.controllers.view:ViewController', action='list_jobs', source=c.harvest_source.name)}}</li>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block primary %}
|
||||||
|
|
||||||
|
<article class="module">
|
||||||
|
<div class="module-content">
|
||||||
|
<h1 class="page-heading">{{ _('Harvest Jobs') }}</h1>
|
||||||
|
|
||||||
|
{% if c.jobs|length == 0 %}
|
||||||
|
<p>{{ _('No jobs yet for this source') }}</p>
|
||||||
|
{% else %}
|
||||||
|
<table class="table table-striped table-bordered table-condensed error-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ _('Created') }}</th>
|
||||||
|
<th>{{ _('Finished') }}</th>
|
||||||
|
<th>{{ _('Status') }}</th>
|
||||||
|
<th>{{ _('Added') }}</th>
|
||||||
|
<th>{{ _('Updated') }}</th>
|
||||||
|
<th>{{ _('Deleted') }}</th>
|
||||||
|
<th>{{ _('Errors') }}</th>
|
||||||
|
<th>{{ _('Full report') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for job in c.jobs %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ h.render_datetime(job.gather_started, with_hours=True) }}</td>
|
||||||
|
<td>{{ h.render_datetime(job.finished, with_hours=True) }}</td>
|
||||||
|
<td>{{ _(job.status) }}</td>
|
||||||
|
{% for action in ['added', 'updated', 'deleted', 'errored'] %}
|
||||||
|
{% if action in stats and stats[action] > 0 %}
|
||||||
|
<td>{{ stats[action] }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td>0</td>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<td><a href="{{ h.url_for(controller='ckanext.harvest.controllers.view:ViewController', action='show_job', source=c.harvest_source.name, id=job.id) }}">{{ _('view') }}</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{% extends "page.html" %}
|
{% extends "page.html" %}
|
||||||
|
|
||||||
{% block subtitle %}{{ _('Harvest Job Summary')}}{% endblock %}
|
{% block subtitle %}{{ _('Harvest Job Report')}}{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb_content %}
|
{% block breadcrumb_content %}
|
||||||
<li>{{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}</li>
|
<li>{{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}</li>
|
||||||
<li>{{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}</li>
|
<li>{{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}</li>
|
||||||
<li>{{ _('Jobs') }}</li>
|
<li>{{ h.nav_link(_('Jobs'), controller='ckanext.harvest.controllers.view:ViewController', action='list_jobs', source=c.harvest_source.name)}}</li>
|
||||||
{% if c.is_last_job %}
|
{% if c.is_last_job %}
|
||||||
<li class="active">{{ h.nav_link(_('Last'), controller='ckanext.harvest.controllers.view:ViewController', action='show_last_job', source=c.harvest_source.name)}}</li>
|
<li class="active">{{ h.nav_link(_('Last'), controller='ckanext.harvest.controllers.view:ViewController', action='show_last_job', source=c.harvest_source.name)}}</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in New Issue