diff --git a/ckan/templates/snippets/datapusher_status.html b/ckan/templates/snippets/datapusher_status.html index d5ac0108520..863faeee491 100644 --- a/ckan/templates/snippets/datapusher_status.html +++ b/ckan/templates/snippets/datapusher_status.html @@ -4,9 +4,8 @@ #} {% if resource.datastore_active %} - {% set datapusher_enabled = h.get_action('datapusher_enabled') %} - {% if datapusher_enabled %} - {% set job = h.get_action('datapusher_status', data_dict={'resource_id': resource.id}) %} + {% if h.datapusher_enabled() %} + {% set job = h.datapusher_status(resource.id) %} {% set title = _('Datapusher status: {status}.').format(status=job.status) %} {% if job.status == 'unknown' %} diff --git a/ckanext/datastore/logic/action.py b/ckanext/datastore/logic/action.py index 2993bd9b083..8aa76493a6a 100644 --- a/ckanext/datastore/logic/action.py +++ b/ckanext/datastore/logic/action.py @@ -571,16 +571,11 @@ def datapusher_status(context, data_dict): data_dict['resource_id'] = data_dict['id'] res_id = _get_or_bust(data_dict, 'resource_id') - try: - task_id = p.toolkit.get_action('task_status_show')(context, { - 'entity_id': res_id, - 'task_type': 'datapusher', - 'key': 'job_id' - }) - except p.toolkit.ObjectNotFound: - return { - 'status': 'unknown' - } + task_id = p.toolkit.get_action('task_status_show')(context, { + 'entity_id': res_id, + 'task_type': 'datapusher', + 'key': 'job_id' + }) task_key = p.toolkit.get_action('task_status_show')(context, { 'entity_id': res_id, diff --git a/ckanext/datastore/plugin.py b/ckanext/datastore/plugin.py index 232c3e25829..b24dc30446b 100644 --- a/ckanext/datastore/plugin.py +++ b/ckanext/datastore/plugin.py @@ -5,6 +5,7 @@ import ckanext.datastore.logic.action as action import ckanext.datastore.logic.auth as auth import ckanext.datastore.db as db +import ckanext.datastore.helpers as helpers import ckan.logic as logic import ckan.model as model @@ -26,6 +27,7 @@ class DatastorePlugin(p.SingletonPlugin): p.implements(p.IDomainObjectModification, inherit=True) p.implements(p.IRoutes, inherit=True) p.implements(p.IResourceController, inherit=True) + p.implements(p.ITemplateHelpers) legacy_mode = False resource_show_action = None @@ -293,3 +295,8 @@ def before_show(self, resource_dict): controller='ckanext.datastore.controller:DatastoreController', action='dump', resource_id=resource_dict['id']) return resource_dict + + def get_helpers(self): + return { + 'datapusher_status': helpers.datapusher_status, + 'datapusher_enabled': helpers.datapusher_enabled}