summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-09-09 14:14:14 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-10-15 19:33:00 +0200
commit561853a625afa41ed3941a32b2453af560a90c1a (patch)
treed4661d08b1e0d05a448fad9148e36d6b4a593224
parentff0ae065d334483be6c96acadb9f32af4bcb5395 (diff)
downloadIshtar-561853a625afa41ed3941a32b2453af560a90c1a.tar.bz2
Ishtar-561853a625afa41ed3941a32b2453af560a90c1a.zip
🐛 GIS API: do not crash on bad importer configuration
-rw-r--r--ishtar_common/views_api.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/ishtar_common/views_api.py b/ishtar_common/views_api.py
index 14cf6b43c..fe301b04d 100644
--- a/ishtar_common/views_api.py
+++ b/ishtar_common/views_api.py
@@ -26,6 +26,7 @@ from urllib.parse import unquote_plus
from rest_framework import serializers, status
from rest_framework.response import Response
+from ishtar_common.data_importer import ImporterError
from ishtar_common.models_common import GeneralType
from ishtar_common.models_imports import ImporterType, ImportChunk
from ishtar_common.rest import GISAPIView
@@ -104,17 +105,21 @@ class GISExportAPI(GISBaseImportView, GISAPIView):
dct = {"query": query, "length": self.PAGE_LEN}
if page > 1:
dct["start"] = (page - 1) * self.PAGE_LEN + 1
+ try:
+ importer_class = importer.get_importer_class()
+ cols, col_names = importer.get_columns(importer_class=importer_class)
+ obj_name = importer_class.OBJECT_CLS.__name__.lower()
+ return get_item(importer_class.OBJECT_CLS, "get_" + obj_name, obj_name,
+ own_table_cols=cols)(
+ request, data_type="json", full=False, force_own=False,
+ no_link=True, col_names=col_names,
+ col_types=importer.get_columns_types(),
+ **dct
+ )
+ except ImporterError as e:
+ return Response({"error": str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- importer_class = importer.get_importer_class()
- cols, col_names = importer.get_columns(importer_class=importer_class)
- obj_name = importer_class.OBJECT_CLS.__name__.lower()
- return get_item(importer_class.OBJECT_CLS, "get_" + obj_name, obj_name,
- own_table_cols=cols)(
- request, data_type="json", full=False, force_own=False,
- no_link=True, col_names=col_names,
- col_types=importer.get_columns_types(),
- **dct
- )
class ImportChunkSerializer(serializers.ModelSerializer):