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
15b43573
Commit
15b43573
authored
1 year ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Override default tag_name_validator to allow any tag name
parent
de06e5fa
No related branches found
No related tags found
1 merge request
!48
Merge dev into master
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/tests_wip/test_validation.py
+8
-0
8 additions, 0 deletions
ckanext/odsh/tests_wip/test_validation.py
ckanext/odsh/validation.py
+11
-0
11 additions, 0 deletions
ckanext/odsh/validation.py
with
19 additions
and
0 deletions
ckanext/odsh/tests_wip/test_validation.py
+
8
−
0
View file @
15b43573
...
@@ -105,3 +105,11 @@ def test_validate_licenseAttributionByText():
...
@@ -105,3 +105,11 @@ def test_validate_licenseAttributionByText():
(
'
extras
'
,
0
,
'
key
'
):
'
licenseAttributionByText
'
,
(
'
extras
'
,
0
,
'
key
'
):
'
licenseAttributionByText
'
,
(
'
extras
'
,
0
,
'
value
'
):
''
}
(
'
extras
'
,
0
,
'
value
'
):
''
}
validate_licenseAttributionByText
(
'
key
'
,
data
,
{},
None
)
validate_licenseAttributionByText
(
'
key
'
,
data
,
{},
None
)
def
test_tag_name_validator_invalid
():
with
pytest
.
raises
(
Exception
):
tag_name_validator
(
'
Foo
\n
Bar
'
,
None
)
def
test_tag_name_validator_valid
():
tag_name_validator
(
'
Regionalplan für den Planungsraum_I: (5.8 – Windenergie_an_Land)
'
,
None
)
This diff is collapsed.
Click to expand it.
ckanext/odsh/validation.py
+
11
−
0
View file @
15b43573
...
@@ -293,6 +293,7 @@ def tag_string_convert(key, data, errors, context):
...
@@ -293,6 +293,7 @@ def tag_string_convert(key, data, errors, context):
for
tag
in
tags
:
for
tag
in
tags
:
toolkit
.
get_validator
(
'
tag_length_validator
'
)(
tag
,
context
)
toolkit
.
get_validator
(
'
tag_length_validator
'
)(
tag
,
context
)
tag_name_validator
(
tag
,
context
)
def
validate_relatedPackage
(
data
):
def
validate_relatedPackage
(
data
):
...
@@ -313,6 +314,15 @@ def validate_formats(data, errors):
...
@@ -313,6 +314,15 @@ def validate_formats(data, errors):
return
data
return
data
def
tag_name_validator
(
value
,
context
):
"""
Allow tag name to contain any characters but no newlines
"""
tagname_match
=
re
.
compile
(
r
'
/^(?=.*[^\n])[^\n]*$
'
,
re
.
UNICODE
)
if
not
tagname_match
.
match
(
value
):
raise
toolkit
.
Invalid
(
_
(
'
Invalid tag:
"
%s
"
. Tags cannot contain line breaks.
'
)
%
(
value
))
return
value
def
get_validators
():
def
get_validators
():
return
{
return
{
'
known_spatial_uri
'
:
known_spatial_uri
,
'
known_spatial_uri
'
:
known_spatial_uri
,
...
@@ -320,4 +330,5 @@ def get_validators():
...
@@ -320,4 +330,5 @@ def get_validators():
'
validate_licenseAttributionByText
'
:
validate_licenseAttributionByText
,
'
validate_licenseAttributionByText
'
:
validate_licenseAttributionByText
,
'
validate_relatedPackage
'
:
validate_relatedPackage
,
'
validate_relatedPackage
'
:
validate_relatedPackage
,
'
odsh_validate_format
'
:
validate_formats
,
'
odsh_validate_format
'
:
validate_formats
,
'
tag_name_validator
'
:
tag_name_validator
,
}
}
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