Add refresh link to the UI.

This commit is contained in:
Adrià Mercader 2011-03-10 17:24:23 +00:00
parent 4f2a233cf1
commit 70bff06b48
3 changed files with 11 additions and 27 deletions

View File

@ -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):

View File

@ -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

View File

@ -26,8 +26,7 @@
<tr py:for="source in c.sources">
<td>${h.link_to('view', 'harvest/' + source.id)}</td>
<td>refresh</td>
<td>${h.link_to('refresh', 'harvest/' + source.id + '/refresh')}</td>
<td>${source.url}</td>
<td>${source.status.last_harvest_status}</td>
<td>${source.status.overall_statistics.added} pkgs ${source.status.overall_statistics.errors} errors</td>