diff --git a/api/utils/serializer/serializer.py b/api/utils/serializer/serializer.py index f4a35bdc..0af19359 100644 --- a/api/utils/serializer/serializer.py +++ b/api/utils/serializer/serializer.py @@ -10,9 +10,11 @@ from abc import abstractmethod from django.contrib.gis import geos from django.contrib.gis.geos import GEOSGeometry +from django.core.exceptions import ObjectDoesNotExist from django.core.paginator import Paginator from django.db.models import Q +from api.models import ExternalIdentifier from konova.models import Geometry from konova.utils.message_templates import DATA_UNSHARED @@ -76,6 +78,14 @@ class AbstractModelAPISerializer: del self.lookup["id"] else: # Return certain object + ## But first check, whether this is an external identifier ... + try: + ## If we can find this _id on our ExternalIdentifier model, we need to map it on the internal id + ext_id = ExternalIdentifier.objects.get(external_id=_id) + _id = ext_id.internal_id + except ObjectDoesNotExist: + # If we did not find it, we assume that this is already an internal id. (Or it does not exist at all) + pass self.lookup["id"] = _id self.shared_lookup = Q(