diff --git a/ckanext/harvest/__init__.py b/ckanext/harvest/__init__.py index 5a5f743..a08e50a 100644 --- a/ckanext/harvest/__init__.py +++ b/ckanext/harvest/__init__.py @@ -35,23 +35,7 @@ class Harvest(SingletonPlugin): def filter(self, stream): return stream - """ - if self.enable_organizations: - from pylons import request, tmpl_context as c - routes = request.environ.get('pylons.routes_dict') - - data = dict(link = h.link_to("Organizations who have published packages with broken resource links.",\ - h.url_for(controller='qa',\ - action='organizations_with_broken_resource_links') - )) - if routes.get('controller') == 'ckanext.qa.controllers.view:ViewController'\ - and routes.get('action') == 'index': - stream = stream | Transformer('body//div[@class="qa-content"]')\ - .append(HTML(html.ORGANIZATION_LINK % data)) - - return stream - """ def before_map(self, map): map.connect('harvest', '/harvest', controller='ckanext.harvest.controllers.view:ViewController', @@ -67,15 +51,14 @@ class Harvest(SingletonPlugin): conditions=dict(method=['POST']), action='create') - map.connect('harvest_create', '/harvest/harvestingjob', - controller='ckanext.harvest.controllers.view:ViewController', - conditions=dict(method=['POST']), - action='create_harvesting_job') - map.connect('harvest_show', '/harvest/:id', controller='ckanext.harvest.controllers.view:ViewController', action='show') - + + map.connect('harvest_create', '/harvest/:id/refresh', + controller='ckanext.harvest.controllers.view:ViewController', + action='create_harvesting_job') + return map def update_config(self, config): diff --git a/ckanext/harvest/controllers/view.py b/ckanext/harvest/controllers/view.py index 17dd65b..ea2cee1 100644 --- a/ckanext/harvest/controllers/view.py +++ b/ckanext/harvest/controllers/view.py @@ -72,15 +72,17 @@ class ViewController(BaseController): h.flash_success('Harvesting source added successfully') redirect(h.url_for(controller='harvest', action='index')) - def create_harvesting_job(self): + def create_harvesting_job(self,id): form_url = self.api_url + '/harvestingjob' data = { - 'source_id': request.POST['source_id'], + 'source_id': id, 'user_ref': '' } data = json.dumps(data) r = self._do_request(form_url,data) - return r.read() + + h.flash_success('Refresh requested, harvesting will take place within 15 minutes.') + redirect(h.url_for(controller='harvest', action='index', id=None)) def show(self,id): sources_url = self.api_url + '/harvestsource/%s' % id diff --git a/templates/ckanext/harvest/index.html b/templates/ckanext/harvest/index.html index 7d6e801..4802320 100644 --- a/templates/ckanext/harvest/index.html +++ b/templates/ckanext/harvest/index.html @@ -26,8 +26,7 @@ ${h.link_to('view', 'harvest/' + source.id)} - - refresh + ${h.link_to('refresh', 'harvest/' + source.id + '/refresh')} ${source.url} ${source.status.last_harvest_status} ${source.status.overall_statistics.added} pkgs ${source.status.overall_statistics.errors} errors