Skip to content

Commit

Permalink
[Fixes #12657] Refactor supported type, fix data retriever and refact…
Browse files Browse the repository at this point in the history
…or handlers configuration
  • Loading branch information
mattiagiupponi committed Oct 18, 2024
1 parent 005a00d commit 544b58f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 4.2.9 on 2024-10-18 10:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("resource", "0008_executionrequest_source"),
]

operations = [
migrations.RemoveField(
model_name="executionrequest",
name="source",
),
migrations.AlterField(
model_name="executionrequest",
name="action",
field=models.CharField(
choices=[
("import", "import"),
("upload", "upload"),
("create", "create"),
("copy", "copy"),
("delete", "delete"),
("permissions", "permissions"),
("update", "update"),
("ingest", "ingest"),
("unknown", "unknown"),
],
default="unknown",
max_length=50,
null=True,
),
),
]
4 changes: 2 additions & 2 deletions geonode/upload/handlers/sld/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SLDFileHandler(MetadataFileHandler):
"""

TASKS = {
ira.RESOURCE_SLD_UPLOAD.value: ("start_import", "geonode.upload.import_resource"),
ira.RESOURCE_STYLE_UPLOAD.value: ("start_import", "geonode.upload.import_resource"),
ira.ROLLBACK.value: (
"start_rollback",
"geonode.upload.rollback",
Expand Down Expand Up @@ -66,7 +66,7 @@ def can_handle(_data) -> bool:
return False
return (base.endswith(".sld") if isinstance(base, str) else base.name.endswith(".sld")) and _data.get(
"action", None
) == ira.RESOURCE_SLD_UPLOAD.value
) == ira.RESOURCE_STYLE_UPLOAD.value

@staticmethod
def is_valid(files, user, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions geonode/upload/handlers/sld/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUpClass(cls):
cls.valid_files = {
"base_file": "/tmp/test_sld.sld",
"sld_file": "/tmp/test_sld.sld",
"action": "resource_sld_upload",
"action": "resource_style_upload",
}
cls.owner = get_user_model().objects.first()
cls.layer = create_single_dataset(name="sld_dataset", owner=cls.owner)
Expand All @@ -59,8 +59,8 @@ def test_task_list_is_the_expected_one(self):
"start_import",
"geonode.upload.import_resource",
)
self.assertEqual(len(self.handler.TASKS["resource_sld_upload"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["resource_sld_upload"])
self.assertEqual(len(self.handler.TASKS["resource_style_upload"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["resource_style_upload"])

def test_is_valid_should_raise_exception_if_the_sld_is_invalid(self):
with self.assertRaises(InvalidSldException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_max_upload_parallelism_limit(slug):
class ImporterRequestAction(enum.Enum):
ROLLBACK = _("rollback")
RESOURCE_METADATA_UPLOAD = _("resource_metadata_upload")
RESOURCE_SLD_UPLOAD = _("resource_sld_upload")
RESOURCE_STYLE_UPLOAD = _("resource_style_upload")
REPLACE = _("replace")


Expand Down
2 changes: 1 addition & 1 deletion geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def get_supported_datasets_file_types():
"optional_ext": ["xml", "sld"],
}
],
"action": ["upload", "replace"],
"actions": ["upload", "replace"],
"type": "archive",
}
]
Expand Down

0 comments on commit 544b58f

Please sign in to comment.