Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
Open-Data
ckanext-odsh
Commits
c328f273
Commit
c328f273
authored
6 years ago
by
chbaeh
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://ssh.bitbucket.dataport.de:7999/odsh/ckanext-odsh
parents
d84ebf26
fe0e48d7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po
+6
-1
6 additions, 1 deletion
ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po
ckanext/odsh/validation.py
+46
-28
46 additions, 28 deletions
ckanext/odsh/validation.py
with
52 additions
and
29 deletions
ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po
+
6
−
1
View file @
c328f273
...
...
@@ -373,3 +373,8 @@ msgstr "Linked Data"
msgid "groups: at least one group needed"
msgstr "Bitte geben Sie mindestens eine Kategorie an"
msgid "Tag \"%s\" must be alphanumeric characters or symbols: -_.:()"
msgstr ""
"Tags \"%s\" müssen aus alphnummerischen Zeichen oder diesen Symbolen "
"bestehen: -_.:()"
This diff is collapsed.
Click to expand it.
ckanext/odsh/validation.py
+
46
−
28
View file @
c328f273
...
...
@@ -12,6 +12,11 @@ from ckan.lib.navl.dictization_functions import Missing
from
pylons
import
config
_
=
toolkit
.
_
import
logging
log
=
logging
.
getLogger
(
__name__
)
def
_extract_value
(
data
,
field
):
key
=
None
for
k
in
data
.
keys
():
...
...
@@ -24,6 +29,9 @@ def _extract_value(data, field):
def
validate_extra_groups
(
data
,
requireAtLeastOne
,
errors
):
value
=
_extract_value
(
data
,
'
groups
'
)
if
value
!=
None
:
# 'value != None' means the extra key 'groups' was found,
# so the dataset came from manual editing via the web-frontend.
if
not
value
:
if
requireAtLeastOne
:
errors
[
'
groups
'
]
=
'
at least one group needed
'
...
...
@@ -42,7 +50,10 @@ def validate_extra_groups(data, requireAtLeastOne, errors):
for
num
,
group
in
zip
(
range
(
len
(
groups
)),
groups
):
data
[(
'
groups
'
,
num
,
'
id
'
)]
=
group
else
:
# no extra-field 'groups'
# dataset might come from a harvest process
if
not
data
[(
'
groups
'
,
0
,
'
id
'
)]:
errors
[
'
groups
'
]
=
'
at least one group needed
'
def
validate_extras
(
key
,
data
,
errors
,
context
):
extra_errors
=
{}
...
...
@@ -77,8 +88,6 @@ def validate_extra_date_new(key, field, data, optional, errors):
else
:
if
re
.
match
(
r
'
\d\d\d\d-\d\d-\d\d
'
,
value
):
try
:
print
(
'
parse
'
)
print
(
value
)
dt
=
parse
(
value
)
_set_value
(
data
,
field
,
dt
.
isoformat
())
return
...
...
@@ -121,7 +130,6 @@ def validate_licenseAttributionByText(key, data, errors,context):
hasAttribution
=
False
for
k
in
data
:
if
data
[
k
]
==
'
licenseAttributionByText
'
:
print
(
data
[
k
])
if
isinstance
(
data
[(
k
[
0
],
k
[
1
],
'
value
'
)],
Missing
)
or
(
k
[
0
],
k
[
1
],
'
value
'
)
not
in
data
:
del
data
[(
k
[
0
],
k
[
1
],
'
value
'
)]
del
data
[(
k
[
0
],
k
[
1
],
'
key
'
)]
...
...
@@ -130,10 +138,24 @@ def validate_licenseAttributionByText(key, data, errors,context):
value
=
data
[(
k
[
0
],
k
[
1
],
'
value
'
)]
hasAttribution
=
value
!=
''
break
if
not
hasAttribution
:
current_indexes
=
[
k
[
1
]
for
k
in
data
.
keys
()
if
len
(
k
)
>
1
and
k
[
0
]
==
'
extras
'
]
new_index
=
max
(
current_indexes
)
+
1
if
current_indexes
else
0
data
[(
'
extras
'
,
new_index
,
'
key
'
)]
=
'
licenseAttributionByText
'
data
[(
'
extras
'
,
new_index
,
'
value
'
)]
=
''
if
isByLicense
and
not
hasAttribution
:
errors
[
'
licenseAttributionByText
'
]
=
'
empty not allowed
'
raise
toolkit
.
Invalid
(
'
licenseAttributionByText:licenseAttributionByText: empty not allowed
'
)
# errors['licenseAttributionByText'] = 'empty not allowed'
if
not
isByLicense
and
hasAttribution
:
errors
[
'
licenseAttributionByText
'
]
=
'
text not allowed for this license
'
#errors['licenseAttributionByText'] = 'text not allowed for this license'
raise
toolkit
.
Invalid
(
'
licenseAttributionByText: text not allowed for this license
'
)
def
known_spatial_uri
(
key
,
data
,
errors
,
context
):
value
=
_extract_value
(
data
,
'
spatial_uri
'
)
...
...
@@ -179,7 +201,7 @@ def known_spatial_uri(key, data, errors, context):
data
[(
'
extras
'
,
new_index
+
1
,
'
value
'
)]
=
spatial
def
tag_name_validator
(
value
,
context
):
tagname_match
=
re
.
compile
(
'
[\w \-.\:\(\)
äöüÄÖÜß
\´\`]*$
'
,
re
.
UNICODE
)
tagname_match
=
re
.
compile
(
'
[\w \-.\:\(\)\´\`]*$
'
,
re
.
UNICODE
)
if
not
tagname_match
.
match
(
value
):
raise
toolkit
.
Invalid
(
_
(
'
Tag
"
%s
"
must be alphanumeric
'
'
characters or symbols: -_.:()
'
)
%
(
value
))
...
...
@@ -200,10 +222,6 @@ def tag_string_convert(key, data, errors, context):
current_index
=
max
([
int
(
k
[
1
])
for
k
in
data
.
keys
()
if
len
(
k
)
==
3
and
k
[
0
]
==
'
tags
'
]
+
[
-
1
])
print
(
'
TAGS
'
)
print
(
current_index
)
for
num
,
tag
in
zip
(
count
(
current_index
+
1
),
tags
):
data
[(
'
tags
'
,
num
,
'
name
'
)]
=
tag
...
...
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