Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
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
Transparenzportal
ckanext-odsh
Commits
275b9b59
Commit
275b9b59
authored
Aug 6, 2019
by
Daniel Neuwirth
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix collection-resource upload
parent
d799a540
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/helpers_tpsh.py
+26
-0
26 additions, 0 deletions
ckanext/odsh/helpers_tpsh.py
ckanext/odsh/plugin.py
+9
-1
9 additions, 1 deletion
ckanext/odsh/plugin.py
with
35 additions
and
1 deletion
ckanext/odsh/helpers_tpsh.py
+
26
−
0
View file @
275b9b59
...
...
@@ -107,4 +107,30 @@ def tpsh_get_latest_resources_for_type(collection_name, type):
return
latest
def
tpsh_corrects_missing_relationship
(
context
,
pkg_dict
):
'''
This function corrects missing relationship in show package.
Note this fix is only good with one or non relationship.
This error is well known but was not fixed. https://github.com/ckan/ckan/issues/3114
The error causes the deletation of relationships, because package_show is
used in resource_create to get the package.
'''
pkg_id
=
pkg_dict
.
get
(
'
id
'
)
if
model
.
Package
.
get
(
pkg_id
).
get_relationships
():
relationship_from_model
=
model
.
Package
.
get
(
pkg_id
).
get_relationships
()[
0
]
relationship_list
=
pkg_dict
.
get
(
'
relationships_as_subject
'
)
type_pkg
=
pkg_dict
.
get
(
'
type
'
)
if
type_pkg
==
'
dataset
'
and
not
relationship_list
:
relationship_for_package
=
{
'
__extras
'
:
{
'
object_package_id
'
:
relationship_from_model
.
object_package_id
,
'
revision_id
'
:
relationship_from_model
.
revision_id
,
'
subject_package_id
'
:
relationship_from_model
.
subject_package_id
,
'
comment
'
:
relationship_from_model
.
subject_package_id
,
'
id
'
:
relationship_from_model
.
id
,
'
type
'
:
relationship_from_model
.
type
}}
pkg_dict
[
'
relationships_as_subject
'
].
append
(
relationship_for_package
)
return
pkg_dict
This diff is collapsed.
Click to expand it.
ckanext/odsh/plugin.py
+
9
−
1
View file @
275b9b59
...
...
@@ -15,6 +15,7 @@ from ckan.lib.plugins import DefaultTranslation, DefaultDatasetForm
from
ckan.logic.validators
import
tag_string_convert
import
ckan.plugins
as
plugins
import
ckan.plugins.toolkit
as
toolkit
import
ckan.model
as
model
# imports from this extension
import
ckanext.odsh.helpers
as
odsh_helpers
...
...
@@ -159,6 +160,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
# key:
'
daterange_prettified
'
, value: string with prettified version
of daterange between date_start and date_end
'''
pkg_dict
=
helpers_tpsh
.
tpsh_corrects_missing_relationship
(
context
,
pkg_dict
)
self
.
_update_successor_and_predecessor_urls_in_pkg_dict
(
context
,
pkg_dict
)
self
.
_update_is_new_in_pkg_dict
(
pkg_dict
)
self
.
_update_daterange_prettified_in_pkg_dict
(
pkg_dict
)
...
...
@@ -212,6 +214,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
return
dict_pkg
# IRoutes
def
before_map
(
self
,
map
):
...
...
@@ -436,3 +440,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
score
=
s
if
score
>
0
:
dict_pkg
[
'
openness
'
]
=
OdshPlugin
.
scores
[
score
-
1
]
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