#208 API non existing atomID

* handles error response for non existing atomID properly according to isse #208
pull/212/head
mpeltriaux 2 years ago
parent cd914c880f
commit 109a45c564

@ -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
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):

Loading…
Cancel
Save