Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #271] XML and SLD raise error during import #272

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading