Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Transparenzportal
ckanext-odsh
Commits
f58ddf36
Commit
f58ddf36
authored
6 years ago
by
Dennis Rupnow
Browse files
Options
Downloads
Patches
Plain Diff
checks if field is already in extras
parent
26a53392
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/plugin.py
+21
-3
21 additions, 3 deletions
ckanext/odsh/plugin.py
with
21 additions
and
3 deletions
ckanext/odsh/plugin.py
+
21
−
3
View file @
f58ddf36
...
...
@@ -8,6 +8,7 @@ from ckan.common import OrderedDict
from
ckanext.odsh.lib.uploader
import
ODSHResourceUpload
import
ckan.lib.helpers
as
helpers
import
helpers
as
odsh_helpers
import
ckan.lib.navl.dictization_functions
as
df
from
itertools
import
count
from
routes.mapper
import
SubMapper
...
...
@@ -21,6 +22,8 @@ import logging
log
=
logging
.
getLogger
(
__name__
)
_
=
toolkit
.
_
missing
=
df
.
missing
StopOnError
=
df
.
StopOnError
def
odsh_get_facet_items_dict
(
name
,
limit
=
None
):
'''
...
...
@@ -130,6 +133,20 @@ def odsh_tag_string_convert(key, data, errors, context):
toolkit
.
get_validator
(
'
tag_length_validator
'
)(
tag
,
context
)
odsh_tag_name_validator
(
tag
,
context
)
def
odsh_not_empty
(
key
,
data
,
errors
,
context
):
simple_value
=
data
.
get
(
key
)
in_extras
=
False
if
key
is
not
missing
:
simple_key
=
key
[
0
]
for
data_key
,
data_value
in
data
.
iteritems
():
if
data_key
[
0
]
==
'
extras
'
and
data_value
==
simple_key
:
in_extras
=
True
if
(
not
simple_value
or
simple_value
is
missing
)
and
not
in_extras
:
errors
[
key
].
append
(
_
(
'
Missing value
'
))
raise
StopOnError
class
OdshIcapPlugin
(
plugins
.
SingletonPlugin
):
plugins
.
implements
(
plugins
.
IUploader
,
inherit
=
True
)
...
...
@@ -246,12 +263,12 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
elif
field
==
'
spatial_uri
'
:
schema
.
update
({
field
:
[
toolkit
.
get_converter
(
'
not_empty
'
),
toolkit
.
get_converter
(
'
odsh_
not_empty
'
),
toolkit
.
get_converter
(
'
known_spatial_uri
'
),
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
else
:
schema
.
update
({
field
:
[
toolkit
.
get_converter
(
'
not_empty
'
),
toolkit
.
get_converter
(
'
odsh_
not_empty
'
),
toolkit
.
get_converter
(
'
convert_to_extras
'
)]})
for
field
in
self
.
_fields
():
schema
.
update
({
field
:
[
toolkit
.
get_converter
(
'
not_empty
'
)]})
...
...
@@ -298,5 +315,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
def
get_validators
(
self
):
return
{
'
odsh_convert_groups_string
'
:
odsh_convert_groups_string
,
'
known_spatial_uri
'
:
known_spatial_uri
,
'
odsh_tag_name_validator
'
:
odsh_tag_name_validator
}
'
odsh_tag_name_validator
'
:
odsh_tag_name_validator
,
'
odsh_not_empty
'
:
odsh_not_empty
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment