Only try to create/match a organization if there is a remote_org
This commit is contained in:
parent
dd1acd0c6b
commit
8b5d70c6fe
|
@ -309,22 +309,23 @@ class CKANHarvester(HarvesterBase):
|
||||||
remote_org = package_dict['owner_org']
|
remote_org = package_dict['owner_org']
|
||||||
context = {'model': model, 'session': Session, 'user': 'harvest'}
|
context = {'model': model, 'session': Session, 'user': 'harvest'}
|
||||||
|
|
||||||
try:
|
if remote_org:
|
||||||
data_dict = {'id': remote_org}
|
try:
|
||||||
org = get_action('organization_show')(context, data_dict)
|
data_dict = {'id': remote_org}
|
||||||
validated_org = org['id']
|
org = get_action('organization_show')(context, data_dict)
|
||||||
except NotFound, e:
|
validated_org = org['id']
|
||||||
log.info('Organization %s is not available' % remote_org)
|
except NotFound, e:
|
||||||
if remote_orgs == 'create':
|
log.info('Organization %s is not available' % remote_org)
|
||||||
try:
|
if remote_orgs == 'create':
|
||||||
org = self._get_group(harvest_object.source.url, remote_org)
|
try:
|
||||||
for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']:
|
org = self._get_group(harvest_object.source.url, remote_org)
|
||||||
org.pop(key, None)
|
for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']:
|
||||||
get_action('organization_create')(context, org)
|
org.pop(key, None)
|
||||||
log.info('Organization %s has been newly created' % remote_org)
|
get_action('organization_create')(context, org)
|
||||||
validated_org = org['id']
|
log.info('Organization %s has been newly created' % remote_org)
|
||||||
except:
|
validated_org = org['id']
|
||||||
log.error('Could not get remote org %s' % remote_org)
|
except:
|
||||||
|
log.error('Could not get remote org %s' % remote_org)
|
||||||
|
|
||||||
package_dict['owner_org'] = validated_org
|
package_dict['owner_org'] = validated_org
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue