[#71] CKAN harvester: Add datasets to source organization
If the harvest source belongs to an organization, new datasets should be added to it. This is already the case in the spatial harvesters. The remote orgs logic has been kept, with the difference that if for some reason the remote org can not be assigned, the local one is used. If the source does not have an organization, none is added.
This commit is contained in:
parent
0a845b6308
commit
c18d9dc3af
|
@ -296,10 +296,17 @@ class CKANHarvester(HarvesterBase):
|
|||
|
||||
package_dict['groups'] = validated_groups
|
||||
|
||||
context = {'model': model, 'session': Session, 'user': 'harvest'}
|
||||
|
||||
# Local harvest source organization
|
||||
source_dataset = get_action('package_show')(context, {'id': harvest_object.source.id})
|
||||
local_org = source_dataset.get('owner_org')
|
||||
|
||||
remote_orgs = self.config.get('remote_orgs', None)
|
||||
|
||||
if not remote_orgs in ('only_local', 'create'):
|
||||
# Ignore remote groups
|
||||
package_dict.pop('owner_org', None)
|
||||
# Assign dataset to the source organization
|
||||
package_dict['owner_org'] = local_org
|
||||
else:
|
||||
if not 'owner_org' in package_dict:
|
||||
package_dict['owner_org'] = None
|
||||
|
@ -307,7 +314,6 @@ class CKANHarvester(HarvesterBase):
|
|||
# check if remote org exist locally, otherwise remove
|
||||
validated_org = None
|
||||
remote_org = package_dict['owner_org']
|
||||
context = {'model': model, 'session': Session, 'user': 'harvest'}
|
||||
|
||||
if remote_org:
|
||||
try:
|
||||
|
@ -327,7 +333,7 @@ class CKANHarvester(HarvesterBase):
|
|||
except:
|
||||
log.error('Could not get remote org %s' % remote_org)
|
||||
|
||||
package_dict['owner_org'] = validated_org
|
||||
package_dict['owner_org'] = validated_org or local_org
|
||||
|
||||
# Set default groups if needed
|
||||
default_groups = self.config.get('default_groups', [])
|
||||
|
|
Loading…
Reference in New Issue