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
765111fe
Commit
765111fe
authored
3 years ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Return 404 for missing collections
parent
67397e0d
No related branches found
No related tags found
2 merge requests
!17
Stage System soll in Zukunft Master Branch erhalten
,
!7
404 Status Code für Abfragen nicht vorhandener Collections
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/collection/controller.py
+3
-1
3 additions, 1 deletion
ckanext/odsh/collection/controller.py
ckanext/odsh/collection/helpers.py
+12
-5
12 additions, 5 deletions
ckanext/odsh/collection/helpers.py
with
15 additions
and
6 deletions
ckanext/odsh/collection/controller.py
+
3
−
1
View file @
765111fe
...
@@ -9,6 +9,8 @@ class LatestDatasetController(PackageController):
...
@@ -9,6 +9,8 @@ class LatestDatasetController(PackageController):
def
latest_dataset
(
self
,
id
):
def
latest_dataset
(
self
,
id
):
latest_dataset
=
get_latest_dataset
(
id
)
latest_dataset
=
get_latest_dataset
(
id
)
if
latest_dataset
is
None
:
toolkit
.
abort
(
404
)
toolkit
.
redirect_to
(
controller
=
'
package
'
,
action
=
'
read
'
,
id
=
latest_dataset
)
toolkit
.
redirect_to
(
controller
=
'
package
'
,
action
=
'
read
'
,
id
=
latest_dataset
)
class
LatestRecourcesController
(
PackageController
):
class
LatestRecourcesController
(
PackageController
):
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/collection/helpers.py
+
12
−
5
View file @
765111fe
...
@@ -10,13 +10,16 @@ def get_collection(dataset_dict):
...
@@ -10,13 +10,16 @@ def get_collection(dataset_dict):
collection_id
=
get_collection_id
(
dataset_dict
)
collection_id
=
get_collection_id
(
dataset_dict
)
if
collection_id
:
if
collection_id
:
return
get_collection_info
(
collection_id
,
dataset_dict
)
return
get_collection_info
(
collection_id
,
dataset_dict
)
return
None
return
None
def
get_collection_info
(
collection_id
,
dataset_dict
=
None
):
def
get_collection_info
(
collection_id
,
dataset_dict
=
None
):
collection_dict
=
get_package_dict
(
collection_id
)
collection_dict
=
get_package_dict
(
collection_id
)
if
not
collection_dict
:
return
None
dataset_names
=
get_dataset_names
(
collection_dict
)
dataset_names
=
get_dataset_names
(
collection_dict
)
if
not
dataset_names
:
return
None
datasets_in_collection
=
get_datasets_from_solr
(
dataset_names
)
datasets_in_collection
=
get_datasets_from_solr
(
dataset_names
)
collection_info
=
gather_collection_info
(
collection_dict
,
datasets_in_collection
,
dataset_dict
)
collection_info
=
gather_collection_info
(
collection_dict
,
datasets_in_collection
,
dataset_dict
)
return
collection_info
return
collection_info
...
@@ -41,6 +44,8 @@ def get_package_dict(name):
...
@@ -41,6 +44,8 @@ def get_package_dict(name):
def
get_dataset_names
(
collection_dict
):
def
get_dataset_names
(
collection_dict
):
if
not
collection_dict
:
return
[]
collection_dict
=
get_package_dict
(
collection_dict
.
get
(
'
id
'
))
# needed to get full package_dict
collection_dict
=
get_package_dict
(
collection_dict
.
get
(
'
id
'
))
# needed to get full package_dict
if
collection_dict
:
if
collection_dict
:
relationships_collection
=
collection_dict
.
get
(
'
relationships
'
)
relationships_collection
=
collection_dict
.
get
(
'
relationships
'
)
...
@@ -159,6 +164,8 @@ def url_last_member(name_collection):
...
@@ -159,6 +164,8 @@ def url_last_member(name_collection):
def
get_latest_dataset
(
collection_name
):
def
get_latest_dataset
(
collection_name
):
collection_info
=
get_collection_info
(
collection_name
)
collection_info
=
get_collection_info
(
collection_name
)
if
not
collection_info
:
return
None
latest_name
=
collection_info
[
'
last_member
'
][
'
name
'
]
latest_name
=
collection_info
[
'
last_member
'
][
'
name
'
]
return
latest_name
return
latest_name
...
...
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