From 696a8dc05808e1ca5b338767fd5468c609e1facf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Mercader?= Date: Fri, 11 Mar 2011 12:41:13 +0000 Subject: [PATCH] Add option to delete harvesting sources --- ckanext/harvest/__init__.py | 4 ++++ ckanext/harvest/controllers/view.py | 9 ++++++++- templates/ckanext/harvest/index.html | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ckanext/harvest/__init__.py b/ckanext/harvest/__init__.py index a08e50a..f922def 100644 --- a/ckanext/harvest/__init__.py +++ b/ckanext/harvest/__init__.py @@ -55,6 +55,10 @@ class Harvest(SingletonPlugin): controller='ckanext.harvest.controllers.view:ViewController', action='show') + map.connect('harvest_show', '/harvest/:id/delete', + controller='ckanext.harvest.controllers.view:ViewController', + action='delete') + map.connect('harvest_create', '/harvest/:id/refresh', controller='ckanext.harvest.controllers.view:ViewController', action='create_harvesting_job') diff --git a/ckanext/harvest/controllers/view.py b/ckanext/harvest/controllers/view.py index 8587331..a695430 100644 --- a/ckanext/harvest/controllers/view.py +++ b/ckanext/harvest/controllers/view.py @@ -83,7 +83,14 @@ class ViewController(BaseController): c.source = json.loads(doc) return render('ckanext/harvest/show.html') - + + def delete(self,id): + form_url = self.form_api_url + '/harvestsource/delete/%s' % id + r = self._do_request(form_url) + + h.flash_success('Harvesting source deleted successfully') + redirect(h.url_for(controller='harvest', action='index', id=None)) + def create_harvesting_job(self,id): form_url = self.api_url + '/harvestingjob' data = { diff --git a/templates/ckanext/harvest/index.html b/templates/ckanext/harvest/index.html index 4802320..e8b3a32 100644 --- a/templates/ckanext/harvest/index.html +++ b/templates/ckanext/harvest/index.html @@ -15,6 +15,7 @@ Add a harvesting source + @@ -26,6 +27,7 @@ +
URL
${h.link_to('view', 'harvest/' + source.id)}${h.link_to('delete', 'harvest/' + source.id + '/delete')} ${h.link_to('refresh', 'harvest/' + source.id + '/refresh')} ${source.url} ${source.status.last_harvest_status}