Commit 5b59c2c9 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[entities] Make it possible to override the CKAN organization

And thus make the corresponding configuration option optional.
parent 4d8fea13570d
......@@ -72,6 +72,11 @@ class CKANPublishableAdapter(EntityAdapter):
return [d['url'] for d in res['resources']]
return []
@property
def ckan_organization(self):
"""The CKAN organization which should own the dataset"""
return self._cw.vreg.config.get('ckan-organization')
def ckan_get_organization_id(self, orgname):
"""Retrieve the ID of an organization given its name"""
data = {'organizations': [orgname],
......@@ -94,9 +99,9 @@ class CKANPublishableAdapter(EntityAdapter):
'notes': self.ckan_notes(),
'maintainer': None,
'maintainer_email': None,
'owner_org':self.ckan_get_organization_id(
self.ckan_organization)
}
orgname = self._cw.vreg.config.get('ckan-organization')
data['owner_org'] = self.ckan_get_organization_id(orgname)
maintainer = self.dataset_maintainer()
if maintainer:
data['maintainer'] = maintainer.dc_long_title()
......
......@@ -15,7 +15,6 @@ options = (
}),
('ckan-organization',
{'type' : 'string',
'default': REQUIRED,
'help': u'the organization under which dataset will be created',
'group': 'ckan', 'level': 0,
}),
......
......@@ -48,7 +48,7 @@ def ckan_instance_configured(cls, req, **kwargs):
(Mostly useful in tests to disable CKAN hooks.)
"""
config = req.vreg.config
for option in ('ckan-baseurl', 'ckan-api-key', 'ckan-organization'):
for option in ('ckan-baseurl', 'ckan-api-key'):
if not config.get(option):
req.warning('CKAN instance configuration incomplete, missing "%s" '
'option' % option)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment