From cc027dcd6b9a1f30a766bf6ff5bd4a05962cb786 Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Tue, 20 Aug 2024 10:46:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[BUG]=20Fix=20APIv2=20exception?= =?UTF-8?q?=20on=20HD=20Views=20without=20Annotations=20(#4032)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.rst | 6 +++++- geotrek/api/v2/serializers.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 228e22b396..2c2bfee0d6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -7,7 +7,11 @@ CHANGELOG **Improvements** -- Allow use of Annotation Categories on annotations other than Points (#4032)" +- Allow use of Annotation Categories on annotations other than Points (#4032) + +**Bug fixes** + +- Fix APIv2 exception on HD Views without Annotations (#4032) **Documentation** diff --git a/geotrek/api/v2/serializers.py b/geotrek/api/v2/serializers.py index 501b8faede..d831bf01f4 100644 --- a/geotrek/api/v2/serializers.py +++ b/geotrek/api/v2/serializers.py @@ -403,7 +403,7 @@ def get_poi(self, obj): def get_annotations(self, obj): annotations = obj.annotations annotations_categories = obj.annotations_categories - for feature in annotations["features"]: + for feature in annotations.get("features", []): feat_id = feature["properties"]["annotationId"] feat_type = feature["geometry"]["type"] if feat_type == "Point" and str(feat_id) in annotations_categories.keys():