Skip to content

Commit

Permalink
Issue #5 remove has_app_context check
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVerstraelen authored and soxofaan committed Sep 16, 2022
1 parent 3747406 commit 26d78c1
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 196 deletions.
31 changes: 15 additions & 16 deletions src/openeo_aggregator/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,21 @@ def _normalize_metadata(self, metadata: dict) -> dict:
cid = metadata.get("id", None)
if cid is None:
raise OpenEOApiException("Missing collection id in metadata")
if has_app_context():
if "links" not in metadata:
metadata["links"] = []
metadata["links"] = [l for l in metadata["links"] if l.get("rel") not in ("self", "parent", "root")]
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "root"
})
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "parent"
})
metadata["links"].append({
"href": url_for("openeo.collection_by_id", collection_id=cid, _external=True),
"rel": "self"
})
if "links" not in metadata:
metadata["links"] = []
metadata["links"] = [l for l in metadata["links"] if l.get("rel") not in ("self", "parent", "root")]
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "root"
})
metadata["links"].append({
"href": url_for("openeo.collections", _external=True),
"rel": "parent"
})
metadata["links"].append({
"href": url_for("openeo.collection_by_id", collection_id=cid, _external=True),
"rel": "self"
})
return metadata

def _merge_collection_metadata(self, by_backend: Dict[str, dict]) -> dict:
Expand Down
Loading

0 comments on commit 26d78c1

Please sign in to comment.