[#5] Add helper function for generating a link to a harvest object
This commit is contained in:
parent
daa9a385ff
commit
d4b6dcb7f6
|
@ -63,3 +63,19 @@ def harvest_frequencies():
|
||||||
|
|
||||||
return [{'text': p.toolkit._(f.title()), 'value': f}
|
return [{'text': p.toolkit._(f.title()), 'value': f}
|
||||||
for f in UPDATE_FREQUENCIES]
|
for f in UPDATE_FREQUENCIES]
|
||||||
|
|
||||||
|
def link_for_harvest_object(id=None, guid=None, text=None):
|
||||||
|
|
||||||
|
if not id and not guid:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if guid:
|
||||||
|
context = {'model': model, 'user': p.toolkit.c.user or p.toolkit.c.author}
|
||||||
|
obj =logic.get_action('harvest_object_show')(context, {'id': guid, 'attr': 'guid'})
|
||||||
|
id = obj.id
|
||||||
|
|
||||||
|
url = h.url_for('harvest_object_show', id=id)
|
||||||
|
text = text or guid or id
|
||||||
|
link = '<a href="{url}">{text}</a>'.format(url=url, text=text)
|
||||||
|
|
||||||
|
return p.toolkit.literal(link)
|
||||||
|
|
|
@ -214,7 +214,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
||||||
map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller,
|
map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller,
|
||||||
action='create_harvesting_job')
|
action='create_harvesting_job')
|
||||||
|
|
||||||
map.connect('/harvest/object/:id', controller=controller, action='show_object')
|
map.connect('harvest_object_show', '/harvest/object/:id', controller=controller, action='show_object')
|
||||||
|
|
||||||
map.connect('harvest_job_show_last', '/' + DATASET_TYPE_NAME + '/{source}/job/last', controller=controller, action='show_last_job')
|
map.connect('harvest_job_show_last', '/' + DATASET_TYPE_NAME + '/{source}/job/last', controller=controller, action='show_last_job')
|
||||||
map.connect('harvest_job_show', '/' + DATASET_TYPE_NAME + '/{source}/job/{id}', controller=controller, action='show_job')
|
map.connect('harvest_job_show', '/' + DATASET_TYPE_NAME + '/{source}/job/{id}', controller=controller, action='show_job')
|
||||||
|
@ -260,6 +260,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
||||||
'harvesters_info': harvest_helpers.harvesters_info,
|
'harvesters_info': harvest_helpers.harvesters_info,
|
||||||
'harvester_types': harvest_helpers.harvester_types,
|
'harvester_types': harvest_helpers.harvester_types,
|
||||||
'harvest_frequencies': harvest_helpers.harvest_frequencies,
|
'harvest_frequencies': harvest_helpers.harvest_frequencies,
|
||||||
|
'link_for_harvest_object': harvest_helpers.link_for_harvest_object,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue