Skip to content

Commit

Permalink
[#1183] Don't use get_action because it will be deprecated in #1193
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Aug 15, 2013
1 parent 77060c2 commit 78a289e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions ckan/templates/snippets/datapusher_status.html
Expand Up @@ -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' %}
<i title="{{ _(title) }}" class="datapusher-status status-{{ job.status }} icon-circle icon-large"></i>
Expand Down
15 changes: 5 additions & 10 deletions ckanext/datastore/logic/action.py
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions ckanext/datastore/plugin.py
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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}

0 comments on commit 78a289e

Please sign in to comment.