Merge branch 'add-harvesting-of-organizations' of git://github.com/metaodi/ckanext-harvest into metaodi-add-harvesting-of-organizations
This commit is contained in:
commit
49999893e7
|
@ -308,23 +308,24 @@ class CKANHarvester(HarvesterBase):
|
|||
validated_org = None
|
||||
remote_org = package_dict['owner_org']
|
||||
context = {'model': model, 'session': Session, 'user': 'harvest'}
|
||||
|
||||
try:
|
||||
data_dict = {'id': remote_org}
|
||||
org = get_action('organization_show')(context, data_dict)
|
||||
validated_org = org['id']
|
||||
except NotFound, e:
|
||||
log.info('Organization %s is not available' % remote_org)
|
||||
if remote_orgs == 'create':
|
||||
try:
|
||||
org = self._get_group(harvest_object.source.url, remote_org)
|
||||
for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']:
|
||||
org.pop(key, None)
|
||||
get_action('organization_create')(context, org)
|
||||
log.info('Organization %s has been newly created' % remote_org)
|
||||
validated_org = org['id']
|
||||
except:
|
||||
log.error('Could not get remote org %s' % remote_org)
|
||||
|
||||
if remote_org:
|
||||
try:
|
||||
data_dict = {'id': remote_org}
|
||||
org = get_action('organization_show')(context, data_dict)
|
||||
validated_org = org['id']
|
||||
except NotFound, e:
|
||||
log.info('Organization %s is not available' % remote_org)
|
||||
if remote_orgs == 'create':
|
||||
try:
|
||||
org = self._get_group(harvest_object.source.url, remote_org)
|
||||
for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']:
|
||||
org.pop(key, None)
|
||||
get_action('organization_create')(context, org)
|
||||
log.info('Organization %s has been newly created' % remote_org)
|
||||
validated_org = org['id']
|
||||
except:
|
||||
log.error('Could not get remote org %s' % remote_org)
|
||||
|
||||
package_dict['owner_org'] = validated_org
|
||||
|
||||
|
|
Loading…
Reference in New Issue