Skip to content
Snippets Groups Projects
Commit e1cf96e7 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Merge branch '26-500-error-bei-abfragen-nicht-vorhandener-collections' into 'v1.3'

404 Status Code für Abfragen nicht vorhandener Collections

See merge request !7
parents 67397e0d 765111fe
No related branches found
No related tags found
2 merge requests!17Stage System soll in Zukunft Master Branch erhalten,!7404 Status Code für Abfragen nicht vorhandener Collections
...@@ -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):
......
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment