diff --git a/ckanext/harvest/logic/action/get.py b/ckanext/harvest/logic/action/get.py index 2415278..a8e00e7 100644 --- a/ckanext/harvest/logic/action/get.py +++ b/ckanext/harvest/logic/action/get.py @@ -130,7 +130,9 @@ def harvest_source_list(context, data_dict): sources = _get_sources_for_user(context, data_dict) - return [harvest_source_dictize(source, context) for source in sources] + last_job_status = p.toolkit.asbool(data_dict.get('return_last_job_status', False)) + + return [harvest_source_dictize(source, context, last_job_status) for source in sources] @side_effect_free diff --git a/ckanext/harvest/logic/dictization.py b/ckanext/harvest/logic/dictization.py index 877ea19..53d1392 100644 --- a/ckanext/harvest/logic/dictization.py +++ b/ckanext/harvest/logic/dictization.py @@ -1,15 +1,12 @@ from sqlalchemy import distinct, func from ckan.model import Package, Group +from ckan import logic from ckanext.harvest.model import (HarvestSource, HarvestJob, HarvestObject, HarvestGatherError, HarvestObjectError) -def harvest_source_dictize(source, context): - ''' - TODO: Deprecated - ''' - +def harvest_source_dictize(source, context, last_job_status=False): out = source.as_dict() out['publisher_title'] = u'' @@ -22,6 +19,10 @@ def harvest_source_dictize(source, context): out['status'] = _get_source_status(source, context) + if last_job_status: + source_status = logic.get_action('harvest_source_show_status')(context, {'id': source.id}) + out['last_job_status'] = source_status.get('last_job', {}) + return out