From c5f8e0c7057f5f9db6e54796270d9428f0059bd9 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Thu, 29 Sep 2022 10:29:33 +0200 Subject: [PATCH 1/2] Fix geometry conflict message * fixes bug where geometry conflicts template message has been rendered despite having no active geometry conflict * happened in case of existing geometry conflicts related to an as deleted marked entry --- konova/models/object.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/konova/models/object.py b/konova/models/object.py index 8af95e18..015d34ef 100644 --- a/konova/models/object.py +++ b/konova/models/object.py @@ -698,18 +698,16 @@ class GeoReferencedMixin(models.Model): return request instance_objs = [] - add_message = False conflicts = self.geometry.conflicts_geometries.all() for conflict in conflicts: instance_objs += conflict.affected_geometry.get_data_objects() - add_message = True conflicts = self.geometry.conflicted_by_geometries.all() for conflict in conflicts: instance_objs += conflict.conflicting_geometry.get_data_objects() - add_message = True + add_message = len(instance_objs) > 0 if add_message: instance_identifiers = [x.identifier for x in instance_objs] instance_identifiers = ", ".join(instance_identifiers) From b4cc919b02a308cade33d474e52c0d5fb2833bc3 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Thu, 29 Sep 2022 10:42:32 +0200 Subject: [PATCH 2/2] #208 API non existing atomID * handles error response for non existing atomID properly according to isse #208 --- api/utils/serializer/v1/serializer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/utils/serializer/v1/serializer.py b/api/utils/serializer/v1/serializer.py index 9d3b9dfb..fe979775 100644 --- a/api/utils/serializer/v1/serializer.py +++ b/api/utils/serializer/v1/serializer.py @@ -9,6 +9,7 @@ Created on: 24.01.22 import json from django.contrib.gis.geos import MultiPolygon +from django.core.exceptions import ObjectDoesNotExist from django.db.models import QuerySet from api.utils.serializer.serializer import AbstractModelAPISerializer @@ -80,10 +81,14 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer): json_str = str(json_str) if len(json_str) == 0: return None - code = KonovaCode.objects.get( - atom_id=json_str, - code_lists__in=[code_list_identifier] - ) + try: + code = KonovaCode.objects.get( + atom_id=json_str, + code_lists__in=[code_list_identifier] + ) + except ObjectDoesNotExist as e: + msg = f"{e.args[0]} ({json_str} not found in official list {code_list_identifier})" + raise ObjectDoesNotExist(msg) return code def _created_on_to_json(self, entry):