Skip to content

Commit

Permalink
[Fixes #271] XML and SLD raise error during import (#272)
Browse files Browse the repository at this point in the history
* [Fixes #271] XML and SLD raise error during import
  • Loading branch information
mattiagiupponi authored Aug 28, 2024
1 parent bec2c22 commit 924b6f4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
run: docker compose -f "docker-compose-test.yaml" down
39 changes: 1 addition & 38 deletions importer/handlers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions importer/handlers/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def has_serializer(data) -> bool:
return MetadataFileSerializer
return False

@property
def supported_file_extension_config(self):
return {}

@staticmethod
def extract_params_from_data(_data, action=None):
"""
Expand Down
20 changes: 20 additions & 0 deletions importer/handlers/sld/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions importer/handlers/xml/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 924b6f4

Please sign in to comment.