summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):