From 84e2395bb64a512fb216d212fd42e9206423eb43 Mon Sep 17 00:00:00 2001 From: Mattia Date: Wed, 28 Aug 2024 16:40:51 +0200 Subject: [PATCH 1/2] [Fixes #271] XML and SLD raise error during import --- importer/handlers/apps.py | 39 +--------------------------- importer/handlers/common/metadata.py | 4 --- importer/handlers/sld/handler.py | 20 ++++++++++++++ importer/handlers/xml/handler.py | 20 ++++++++++++++ 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/importer/handlers/apps.py b/importer/handlers/apps.py index 729a15d9..0dd0eaa6 100644 --- a/importer/handlers/apps.py +++ b/importer/handlers/apps.py @@ -34,44 +34,7 @@ def run_setup_hooks(*args, **kwargs): if import_string(module_path)().supported_file_extension_config ] # injecting the new config required for FE - supported_type = [ - { - "id": "xml", - "label": "XML Metadata File", - "format": "metadata", - "ext": ["xml"], - "mimeType": ["application/json"], - "needsFiles": [ - "shp", - "prj", - "dbf", - "shx", - "csv", - "tiff", - "zip", - "sld", - "geojson", - ], - }, - { - "id": "sld", - "label": "Styled Layer Descriptor (SLD)", - "format": "metadata", - "ext": ["sld"], - "mimeType": ["application/json"], - "needsFiles": [ - "shp", - "prj", - "dbf", - "shx", - "csv", - "tiff", - "zip", - "xml", - "geojson", - ], - }, - ] + supported_type = [] supported_type.extend(_available_settings) if not getattr(settings, "ADDITIONAL_DATASET_FILE_TYPES", None): setattr(settings, "ADDITIONAL_DATASET_FILE_TYPES", supported_type) diff --git a/importer/handlers/common/metadata.py b/importer/handlers/common/metadata.py index 14a80454..76fbbcf8 100644 --- a/importer/handlers/common/metadata.py +++ b/importer/handlers/common/metadata.py @@ -35,10 +35,6 @@ def has_serializer(data) -> bool: return MetadataFileSerializer return False - @property - def supported_file_extension_config(self): - return None - @staticmethod def extract_params_from_data(_data, action=None): """ diff --git a/importer/handlers/sld/handler.py b/importer/handlers/sld/handler.py index c93856b0..bc2502ef 100644 --- a/importer/handlers/sld/handler.py +++ b/importer/handlers/sld/handler.py @@ -13,6 +13,26 @@ class SLDFileHandler(MetadataFileHandler): Handler to import SLD files into GeoNode data db It must provide the task_lists required to comple the upload """ + @property + def supported_file_extension_config(self): + return { + "id": "sld", + "label": "Styled Layer Descriptor (SLD)", + "format": "metadata", + "ext": ["sld"], + "mimeType": ["application/json"], + "needsFiles": [ + "shp", + "prj", + "dbf", + "shx", + "csv", + "tiff", + "zip", + "xml", + "geojson", + ], + } @staticmethod def can_handle(_data) -> bool: diff --git a/importer/handlers/xml/handler.py b/importer/handlers/xml/handler.py index 63a74117..f7ca2842 100644 --- a/importer/handlers/xml/handler.py +++ b/importer/handlers/xml/handler.py @@ -13,6 +13,26 @@ class XMLFileHandler(MetadataFileHandler): Handler to import XML files into GeoNode data db It must provide the task_lists required to comple the upload """ + @property + def supported_file_extension_config(self): + return { + "id": "xml", + "label": "XML Metadata File", + "format": "metadata", + "ext": ["xml"], + "mimeType": ["application/json"], + "needsFiles": [ + "shp", + "prj", + "dbf", + "shx", + "csv", + "tiff", + "zip", + "sld", + "geojson", + ], + } @staticmethod def can_handle(_data) -> bool: From 01c0e575fd45995261ed990c2e1773b13758dee7 Mon Sep 17 00:00:00 2001 From: Mattia Date: Wed, 28 Aug 2024 16:43:21 +0200 Subject: [PATCH 2/2] [Fixes #271] fix test --- .github/workflows/runtests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index 7e194f96..0f838eb9 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -15,7 +15,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Start containers - run: docker-compose -f "docker-compose-test.yaml" up -d --build + run: docker compose -f "docker-compose-test.yaml" up -d --build - name: Run django entrypoint run: docker exec django4importer /bin/sh -c "sh /usr/src/importer/entrypoint_test.sh" - name: Run geonode-importer tests @@ -34,4 +34,4 @@ jobs: path: python-coverage-comment-action.txt - name: Stop containers if: always() - run: docker-compose -f "docker-compose-test.yaml" down \ No newline at end of file + run: docker compose -f "docker-compose-test.yaml" down \ No newline at end of file