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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
381f48bf
Commit
381f48bf
authored
6 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
ODPSH-282
parent
0d38561a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ckanext/odsh/plugin.py
+1
-3
1 addition, 3 deletions
ckanext/odsh/plugin.py
ckanext/odsh/templates/package/snippets/package_basic_fields.html
+1
-1
1 addition, 1 deletion
...odsh/templates/package/snippets/package_basic_fields.html
ckanext/odsh/validation.py
+13
-7
13 additions, 7 deletions
ckanext/odsh/validation.py
with
15 additions
and
11 deletions
ckanext/odsh/plugin.py
+
1
−
3
View file @
381f48bf
...
...
@@ -182,12 +182,10 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
schema
[
'
extras
'
].
update
({
'
key
'
:
[
toolkit
.
get_converter
(
'
known_spatial_uri
'
),
toolkit
.
get_converter
(
'
validate_licenseAttributionByText
'
),
]
})
##schema.update({'title': [toolkit.get_converter('odsh_validate_extras')]+ schema['title']})
schema
.
update
({
'
__extras
'
:
[
toolkit
.
get_converter
(
'
odsh_validate_extras
'
)]
})
# eschema = schema['extras']
##schema.update({'extras': None })
def
create_package_schema
(
self
):
schema
=
super
(
OdshPlugin
,
self
).
create_package_schema
()
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/templates/package/snippets/package_basic_fields.html
+
1
−
1
View file @
381f48bf
...
...
@@ -186,7 +186,7 @@ is_required=true,placeholder=_('Enter title')) }}
'/api/2/util/tag/autocomplete?incomplete=?'} %}
{{ form.input('tag_string', id='field-tags', label=_('Tags'), value=data.tag_string, error=errors.tag_string,
classes=['control-full'], attrs=tag_attrs,
is_required=
tru
e, placeholder=_('odsh tags placeholder')) }}
is_required=
fals
e, placeholder=_('odsh tags placeholder')) }}
{% endblock %}
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/validation.py
+
13
−
7
View file @
381f48bf
...
...
@@ -26,6 +26,7 @@ def validate_extra_groups(data, requireAtLeastOne, errors):
if
not
value
:
if
requireAtLeastOne
:
errors
[
'
groups
'
]
=
'
at least one group needed
'
data
[(
'
groups
'
,
0
,
'
id
'
)]
=
''
return
groups
=
[
g
.
strip
()
for
g
in
value
.
split
(
'
,
'
)
if
value
.
strip
()]
...
...
@@ -38,18 +39,19 @@ def validate_extra_groups(data, requireAtLeastOne, errors):
errors
[
'
groups
'
]
=
'
at least one group needed
'
return
for
num
,
tag
in
zip
(
range
(
len
(
groups
)),
groups
):
data
[(
'
groups
'
,
num
,
'
id
'
)]
=
tag
for
num
,
group
in
zip
(
range
(
len
(
groups
)),
groups
):
data
[(
'
groups
'
,
num
,
'
id
'
)]
=
group
def
validate_extras
(
key
,
data
,
errors
,
context
):
extra_errors
=
{}
isStaNord
=
(
'
id
'
,)
in
data
and
data
[(
'
id
'
,)][:
7
]
==
'
StaNord
'
validate_extra_groups
(
data
,
False
,
extra_errors
)
validate_extra_date_new
(
key
,
'
issued
'
,
data
,
False
,
extra_errors
)
validate_extra_date_new
(
key
,
'
issued
'
,
data
,
isStaNord
,
extra_errors
)
validate_extra_date_new
(
key
,
'
temporal_start
'
,
data
,
isStaNord
,
extra_errors
)
validate_extra_date_new
(
key
,
'
temporal_end
'
,
data
,
True
,
extra_errors
)
validate_licenseAttributionByText
(
data
,
extra_errors
)
if
len
(
extra_errors
.
values
()):
raise
toolkit
.
Invalid
(
extra_errors
)
...
...
@@ -107,7 +109,7 @@ def validate_extra_date(key, field, data, optional=False):
def
validate_extra_date_factory
(
field
,
optional
=
False
):
return
lambda
key
,
data
,
errors
,
context
:
validate_extra_date
(
key
,
field
,
data
,
optional
)
def
validate_licenseAttributionByText
(
data
,
errors
):
def
validate_licenseAttributionByText
(
key
,
data
,
errors
,
context
):
register
=
model
.
Package
.
get_license_register
()
isByLicense
=
False
for
k
in
data
:
...
...
@@ -118,7 +120,8 @@ def validate_licenseAttributionByText(data, errors):
hasAttribution
=
False
for
k
in
data
:
if
data
[
k
]
==
'
licenseAttributionByText
'
:
if
isinstance
(
data
[(
k
[
0
],
k
[
1
],
'
value
'
)],
Missing
):
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
'
)]
break
...
...
@@ -191,6 +194,8 @@ 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
):
...
...
@@ -205,5 +210,6 @@ def get_validators():
return
{
'
known_spatial_uri
'
:
known_spatial_uri
,
'
odsh_tag_name_validator
'
:
tag_name_validator
,
'
odsh_validate_extras
'
:
validate_extras
'
odsh_validate_extras
'
:
validate_extras
,
'
validate_licenseAttributionByText
'
:
validate_licenseAttributionByText
}
\ No newline at end of file
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