Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
ckanpublish
Commits
7c8af9dda7d9
Commit
5b59c2c9
authored
Nov 24, 2014
by
Denis Laxalde
Browse files
[entities] Make it possible to override the CKAN organization
And thus make the corresponding configuration option optional.
parent
4d8fea13570d
Changes
3
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
7c8af9dd
...
...
@@ -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
()
...
...
site_cubicweb.py
View file @
7c8af9dd
...
...
@@ -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
,
}),
...
...
utils.py
View file @
7c8af9dd
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment