Skip to content
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
8 changes: 5 additions & 3 deletions geonode/layers/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def __init__(self, *args, **kwargs):
choices = [(None, "-----")]

has_time = serializers.BooleanField(default=False)
attribute = serializers.ChoiceField(choices=[], required=False)
end_attribute = serializers.ChoiceField(choices=[], required=False)
attribute = serializers.ChoiceField(choices=[], required=False, allow_null=True, default=None)
end_attribute = serializers.ChoiceField(choices=[], required=False, allow_null=True, default=None)
presentation = serializers.ChoiceField(
required=False,
choices=[
Expand All @@ -244,9 +244,11 @@ def __init__(self, *args, **kwargs):
"Continuous Intervals for data that is frequently updated, resolution describes the frequency of updates",
),
],
default="LIST",
)
precision_value = serializers.IntegerField(required=False)
precision_value = serializers.IntegerField(required=False, allow_null=True)
precision_step = serializers.ChoiceField(
required=False,
choices=[("years",) * 2, ("months",) * 2, ("days",) * 2, ("hours",) * 2, ("minutes",) * 2, ("seconds",) * 2],
default="seconds",
)
12 changes: 7 additions & 5 deletions geonode/layers/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@
else None
)

if start_attr is None and end_attr is None:
return JsonResponse(

Check warning on line 263 in geonode/layers/api/views.py

View check run for this annotation

Codecov / codecov/patch

geonode/layers/api/views.py#L263

Added line #L263 was not covered by tests
{"message": "Please select at least one option between the attribute and end_attribute"},
status=200,
)

# Save the has_time value to the database
layer.has_time = True
layer.save()
Expand Down Expand Up @@ -288,8 +294,4 @@
layer.has_time = False
layer.save()

return JsonResponse(
{
"message": "The time information was not updated since the time dimension is disabled for this layer"
}
)
return JsonResponse({"message": "The time dimension information for this layer was disabled"})

Check warning on line 297 in geonode/layers/api/views.py

View check run for this annotation

Codecov / codecov/patch

geonode/layers/api/views.py#L297

Added line #L297 was not covered by tests
33 changes: 33 additions & 0 deletions geonode/upload/handlers/common/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from django.db.models import Q
import pyproj
from geonode.geoserver.security import delete_dataset_cache, set_geowebcache_invalidate_cache
from geonode.geoserver.helpers import get_time_info
from geonode.upload.utils import ImporterRequestAction as ira

logger = logging.getLogger("importer")
Expand Down Expand Up @@ -774,8 +775,40 @@
execution_id=str(_exec.exec_id),
asset=get_default_asset(resource),
)

copy_assets_and_links(resource, target=new_resource)

if resource.dataset.has_time is True:

new_resource.has_time = True
new_resource.save()

Check warning on line 784 in geonode/upload/handlers/common/vector.py

View check run for this annotation

Codecov / codecov/patch

geonode/upload/handlers/common/vector.py#L783-L784

Added lines #L783 - L784 were not covered by tests

time_info = None
try:
time_info = get_time_info(resource.dataset)
except ValueError as e:
logger.info(f"Failed to retrieve time information: {e}")

Check warning on line 790 in geonode/upload/handlers/common/vector.py

View check run for this annotation

Codecov / codecov/patch

geonode/upload/handlers/common/vector.py#L786-L790

Added lines #L786 - L790 were not covered by tests

time_info["attribute"] = (

Check warning on line 792 in geonode/upload/handlers/common/vector.py

View check run for this annotation

Codecov / codecov/patch

geonode/upload/handlers/common/vector.py#L792

Added line #L792 was not covered by tests
resource.dataset.attributes.get(pk=time_info.get("attribute")).attribute
if time_info.get("attribute")
else None
)
time_info["end_attribute"] = (

Check warning on line 797 in geonode/upload/handlers/common/vector.py

View check run for this annotation

Codecov / codecov/patch

geonode/upload/handlers/common/vector.py#L797

Added line #L797 was not covered by tests
resource.dataset.attributes.get(pk=time_info.get("end_attribute")).attribute
if time_info.get("end_attribute")
else None
)

resource_manager.exec(

Check warning on line 803 in geonode/upload/handlers/common/vector.py

View check run for this annotation

Codecov / codecov/patch

geonode/upload/handlers/common/vector.py#L803

Added line #L803 was not covered by tests
"set_time_info",
None,
instance=new_resource,
time_info=time_info,
)

new_resource.refresh_from_db()

return new_resource

def get_ogr2ogr_task_group(
Expand Down
Loading