|
38 | 38 | from geonode.upload.handlers.utils import create_alternate, should_be_imported |
39 | 39 | from geonode.upload.models import ResourceHandlerInfo |
40 | 40 | from geonode.upload.orchestrator import orchestrator |
41 | | -from geonode.upload.utils import find_key_recursively |
| 41 | +from geonode.upload.utils import find_key_recursively, ImporterRequestAction as ira |
42 | 42 | from osgeo import gdal |
43 | 43 | from geonode.upload.celery_app import importer_app |
44 | 44 | from geonode.storage.manager import storage_manager |
@@ -123,7 +123,6 @@ def extract_params_from_data(_data, action=None): |
123 | 123 |
|
124 | 124 | return { |
125 | 125 | "skip_existing_layers": _data.pop("skip_existing_layers", "False"), |
126 | | - "overwrite_existing_layer": _data.pop("overwrite_existing_layer", False), |
127 | 126 | "resource_pk": _data.pop("resource_pk", None), |
128 | 127 | "store_spatial_file": _data.pop("store_spatial_files", "True"), |
129 | 128 | "action": _data.pop("action", "upload"), |
@@ -276,7 +275,7 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str: |
276 | 275 | # start looping on the layers available |
277 | 276 | layer_name = self.fixup_name(filename) |
278 | 277 |
|
279 | | - should_be_overwritten = _exec.input_params.get("overwrite_existing_layer") |
| 278 | + should_be_overwritten = _exec.action == ira.REPLACE.value |
280 | 279 | # should_be_imported check if the user+layername already exists or not |
281 | 280 | if should_be_imported( |
282 | 281 | layer_name, |
@@ -318,7 +317,7 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str: |
318 | 317 | "geonode.upload.import_resource", |
319 | 318 | layer_name, |
320 | 319 | alternate, |
321 | | - exa.UPLOAD.value, |
| 320 | + _input.get("action", exa.UPLOAD.value), |
322 | 321 | ) |
323 | 322 | ) |
324 | 323 | return layer_name, alternate, execution_id |
@@ -350,7 +349,7 @@ def create_geonode_resource( |
350 | 349 | getattr(settings, "CASCADE_WORKSPACE", "geonode"), |
351 | 350 | ) |
352 | 351 |
|
353 | | - _overwrite = _exec.input_params.get("overwrite_existing_layer", False) |
| 352 | + _overwrite = _exec.action == ira.REPLACE.value |
354 | 353 | # if the layer exists, we just update the information of the dataset by |
355 | 354 | # let it recreate the catalogue |
356 | 355 | if not saved_dataset.exists() and _overwrite: |
@@ -398,7 +397,7 @@ def overwrite_geonode_resource( |
398 | 397 |
|
399 | 398 | dataset = resource_type.objects.filter(alternate__icontains=alternate, owner=_exec.user) |
400 | 399 |
|
401 | | - _overwrite = _exec.input_params.get("overwrite_existing_layer", False) |
| 400 | + _overwrite = _exec.action == ira.REPLACE.value |
402 | 401 | # if the layer exists, we just update the information of the dataset by |
403 | 402 | # let it recreate the catalogue |
404 | 403 |
|
|
0 commit comments