2012-06-08 18:09:22 +02:00
|
|
|
import logging
|
|
|
|
|
2013-03-12 14:14:07 +01:00
|
|
|
from ckan import plugins as p
|
2012-02-29 16:20:35 +01:00
|
|
|
|
2012-06-08 18:09:22 +02:00
|
|
|
log = logging.getLogger(__name__)
|
2012-02-29 16:20:35 +01:00
|
|
|
|
2015-11-03 21:30:11 +01:00
|
|
|
|
2013-03-12 14:14:07 +01:00
|
|
|
def harvest_source_delete(context, data_dict):
|
|
|
|
'''
|
|
|
|
Deletes an existing harvest source
|
|
|
|
|
|
|
|
This method just proxies the request to package_delete,
|
|
|
|
which will delete the actual harvest type dataset and the
|
|
|
|
HarvestSource object (via the after_delete extension point).
|
|
|
|
|
|
|
|
:param id: the name or id of the harvest source to delete
|
|
|
|
:type id: string
|
|
|
|
|
|
|
|
:returns: the newly created harvest source
|
|
|
|
:rtype: dictionary
|
|
|
|
|
|
|
|
'''
|
2012-06-08 18:09:22 +02:00
|
|
|
log.info('Deleting harvest source: %r', data_dict)
|
2013-03-12 14:14:07 +01:00
|
|
|
|
|
|
|
p.toolkit.check_access('harvest_source_delete', context, data_dict)
|
|
|
|
|
|
|
|
p.toolkit.get_action('package_delete')(context, data_dict)
|
2013-05-20 15:30:22 +02:00
|
|
|
|
|
|
|
if context.get('clear_source', False):
|
|
|
|
|
|
|
|
# We need the id, the name won't work
|
|
|
|
package_dict = p.toolkit.get_action('package_show')(context, data_dict)
|
|
|
|
|
2015-11-03 21:30:11 +01:00
|
|
|
p.toolkit.get_action('harvest_source_clear')(
|
|
|
|
context, {'id': package_dict['id']})
|