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
a05b9a2b
Commit
a05b9a2b
authored
6 years ago
by
anonymous
Browse files
Options
Downloads
Patches
Plain Diff
uses sorting in licenses.json instead of alphabetical order
parent
beded57d
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/helpers.py
+14
-0
14 additions, 0 deletions
ckanext/odsh/helpers.py
ckanext/odsh/plugin.py
+2
-1
2 additions, 1 deletion
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
with
17 additions
and
2 deletions
ckanext/odsh/helpers.py
+
14
−
0
View file @
a05b9a2b
...
...
@@ -168,3 +168,17 @@ def odsh_extract_value_from_extras(extras, key):
if
'
value
'
in
item
:
return
item
[
'
value
'
]
return
None
def
license_options
(
existing_license_id
=
None
):
'''
Returns [(l.title, l.id), ...] for the licenses configured to be
offered. Always includes the existing_license_id, if supplied.
'''
register
=
model
.
Package
.
get_license_register
()
licenses
=
register
.
values
()
license_ids
=
[
license
.
id
for
license
in
licenses
]
if
existing_license_id
and
existing_license_id
not
in
license_ids
:
license_ids
.
insert
(
0
,
existing_license_id
)
return
[
(
license_id
,
register
[
license_id
].
title
if
license_id
in
register
else
license_id
)
for
license_id
in
license_ids
]
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
2
−
1
View file @
a05b9a2b
...
...
@@ -239,7 +239,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'
odsh_encodeurl
'
:
odsh_helpers
.
odsh_encodeurl
,
'
odsh_extract_error
'
:
odsh_helpers
.
odsh_extract_error
,
'
odsh_extract_value_from_extras
'
:
odsh_helpers
.
odsh_extract_value_from_extras
,
'
odsh_create_checksum
'
:
odsh_helpers
.
odsh_create_checksum
'
odsh_create_checksum
'
:
odsh_helpers
.
odsh_create_checksum
,
'
presorted_license_options
'
:
odsh_helpers
.
presorted_license_options
}
def
before_map
(
self
,
map
):
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/templates/package/snippets/package_basic_fields.html
+
1
−
1
View file @
a05b9a2b
...
...
@@ -43,7 +43,7 @@ is_required=true,placeholder=_('Enter title')) }}
<div
class=
"controls"
>
<select
id=
"field-license"
name=
"license_id"
>
{% set existing_license_id = data.get('license_id') %}
{% for license_id, license_desc in h.license_options(existing_license_id) %}
{% for license_id, license_desc in h.
presorted_
license_options(existing_license_id) %}
<option
value=
"{{ license_id }}"
{%
if
existing_license_id=
=license_id
%}
selected=
"selected"
{%
endif
%}
>
{{ license_desc }}
</option>
{% endfor %}
...
...
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