25 lines
624 B
Python
25 lines
624 B
Python
|
from ckan.logic import NotFound
|
||
|
|
||
|
from ckanext.harvest.model import (HarvestSource, HarvestJob)
|
||
|
|
||
|
|
||
|
def harvest_source_delete(context,data_dict):
|
||
|
|
||
|
source_id = data_dict.get('id')
|
||
|
source = HarvestSource.get(source_id)
|
||
|
if not source:
|
||
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||
|
|
||
|
# Don't actually delete the record, just flag it as inactive
|
||
|
source.active = False
|
||
|
source.save()
|
||
|
|
||
|
# Abort any pending jobs
|
||
|
jobs = HarvestJob.filter(source=source,status=u'New')
|
||
|
if jobs:
|
||
|
for job in jobs:
|
||
|
job.status = u'Aborted'
|
||
|
job.save()
|
||
|
|
||
|
return True
|