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
Branches
Tags
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):
def latest_dataset(self, 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)
class LatestRecourcesController(PackageController):
......@@ -35,4 +37,4 @@ class LatestRecourcesController(PackageController):
filename=pre_resource_url,
qualified = True)
toolkit.redirect_to(url_resource)
toolkit.abort(404)
\ No newline at end of file
toolkit.abort(404)
......@@ -10,13 +10,16 @@ def get_collection(dataset_dict):
collection_id = get_collection_id(dataset_dict)
if collection_id:
return get_collection_info(collection_id, dataset_dict)
return None
def get_collection_info(collection_id, dataset_dict=None):
collection_dict = get_package_dict(collection_id)
if not collection_dict:
return None
dataset_names = get_dataset_names(collection_dict)
if not dataset_names:
return None
datasets_in_collection = get_datasets_from_solr(dataset_names)
collection_info = gather_collection_info(collection_dict, datasets_in_collection, dataset_dict)
return collection_info
......@@ -41,13 +44,15 @@ def get_package_dict(name):
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
if collection_dict:
relationships_collection = collection_dict.get('relationships')
names_collection_members = [relationship.get('object') for relationship in relationships_collection]
return names_collection_members
relationships_collection = collection_dict.get('relationships')
names_collection_members = [relationship.get('object') for relationship in relationships_collection]
return names_collection_members
else:
return []
return []
def get_datasets_from_solr(dataset_names):
......@@ -159,6 +164,8 @@ def url_last_member(name_collection):
def get_latest_dataset(collection_name):
collection_info = get_collection_info(collection_name)
if not collection_info:
return None
latest_name = collection_info['last_member']['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