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
5e130fe1
Commit
5e130fe1
authored
1 year ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused imports and minor code formatting
parent
67a8379c
No related branches found
No related tags found
1 merge request
!52
Added applicableLegislation and hvdCategory support
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ckanext/odsh/validation.py
+11
-18
11 additions, 18 deletions
ckanext/odsh/validation.py
with
11 additions
and
18 deletions
ckanext/odsh/validation.py
+
11
−
18
View file @
5e130fe1
...
...
@@ -2,23 +2,15 @@
import
logging
import
csv
import
re
import
urllib.request
import
urllib.error
import
urllib.parse
import
json
import
ckan.logic
as
logic
from
itertools
import
count
from
dateutil.parser
import
parse
import
ckan.plugins.toolkit
as
toolkit
import
ckan.model
as
model
import
pkg_resources
from
dateutil.parser
import
parse
from
ckan.lib.navl.dictization_functions
import
Missing
from
ckanext.odsh.helpers
import
get_package_dict
from
ckanext.odsh.helpers
import
odsh_resource_formats
import
ckan.plugins.toolkit
as
tk
import
pkg_resources
_
=
toolkit
.
_
...
...
@@ -76,14 +68,14 @@ def validate_extras(key, data, errors, context):
harvesting
=
(
'
ignore_auth
'
in
context
)
and
(
context
[
'
ignore_auth
'
]
==
True
)
owner_org
=
data
[(
'
owner_org
'
,)]
lenient_with
=
t
k
.
config
.
get
(
'
ckanext.odsh.lenient_with
'
,
''
)
lenient_with
=
t
oolkit
.
config
.
get
(
'
ckanext.odsh.lenient_with
'
,
''
)
is_optional_temporal_start
=
toolkit
.
asbool
(
t
k
.
config
.
get
(
'
ckanext.odsh.is_optional_temporal_start
'
,
False
)
t
oolkit
.
config
.
get
(
'
ckanext.odsh.is_optional_temporal_start
'
,
False
)
)
or
(
harvesting
and
(
owner_org
in
lenient_with
))
require_at_least_one_category
=
toolkit
.
asbool
(
t
k
.
config
.
get
(
'
ckanext.odsh.require_at_least_one_category
'
,
False
)
t
oolkit
.
config
.
get
(
'
ckanext.odsh.require_at_least_one_category
'
,
False
)
)
validate_extra_groups
(
data
=
data
,
...
...
@@ -195,7 +187,7 @@ def known_spatial_uri(key, data, errors, context):
_copy_spatial_uri_temp_to_extras
(
data
)
value
=
_extract_value
(
data
,
'
spatial_uri
'
)
require_spatial_uri
=
toolkit
.
asbool
(
t
k
.
config
.
get
(
'
ckanext.odsh.require_spatial_uri
'
,
False
)
t
oolkit
.
config
.
get
(
'
ckanext.odsh.require_spatial_uri
'
,
False
)
)
error_message_spatial_uri_empty
=
'
spatial_uri: empty not allowed
'
...
...
@@ -212,7 +204,7 @@ def known_spatial_uri(key, data, errors, context):
has_old_uri
=
old_uri
!=
None
and
len
(
old_uri
)
>
0
if
not
poly
:
poly
=
pkg
.
extras
.
get
(
'
spatial
'
,
None
)
if
(
not
poly
)
and
require_spatial_uri
:
if
not
poly
and
require_spatial_uri
:
raise
toolkit
.
Invalid
(
error_message_spatial_uri_empty
)
# if has_old_uri and require_spatial_uri:
# raise toolkit.Invalid(error_message_spatial_uri_empty)
...
...
@@ -224,7 +216,7 @@ def known_spatial_uri(key, data, errors, context):
return
extension_path
=
pkg_resources
.
resource_filename
(
'
ckanext.odsh
'
,
''
)
mapping_path
=
t
k
.
config
.
get
(
'
ckanext.odsh.spatial.mapping
'
,
mapping_path
=
t
oolkit
.
config
.
get
(
'
ckanext.odsh.spatial.mapping
'
,
extension_path
+
'
/resources/schleswig-holstein_geojson.csv
'
)
not_found
=
True
...
...
@@ -262,7 +254,8 @@ def _copy_spatial_uri_temp_to_extras(data):
from the user interface to extras
'''
extras_data
=
data
.
get
((
'
__extras
'
,))
spatial_uri
=
extras_data
.
get
(
'
spatial_uri_temp
'
)
or
extras_data
.
get
(
'
spatial_url_temp
'
)
spatial_uri
=
extras_data
.
get
(
'
spatial_uri_temp
'
)
or
extras_data
.
get
(
'
spatial_url_temp
'
)
if
_extract_value
(
data
,
'
spatial_uri
'
)
is
None
:
next_index
=
next_extra_index
(
data
)
...
...
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