Skip to content

Commit 5f5d0dc

Browse files
authored
fixing bug related with the thumbnail's update on a map (#13033)
1 parent 050aa97 commit 5f5d0dc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

geonode/base/api/views.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,16 @@ def set_thumbnail_from_bbox(self, request, resource_id, *args, **kwargs):
680680
try:
681681
resource = ResourceBase.objects.get(id=ast.literal_eval(resource_id))
682682

683+
map_thumb_from_bbox = False
684+
if isinstance(resource.get_real_instance(), Map):
685+
map_thumb_from_bbox = True
686+
683687
if not isinstance(resource.get_real_instance(), (Dataset, Map)):
684688
raise NotImplementedError("Not implemented: Endpoint available only for Dataset and Maps")
685689

686690
request_body = request.data if request.data else json.loads(request.body)
687691
try:
692+
# bbox format: (xmin, xmax, ymin, ymax)
688693
bbox = request_body["bbox"] + [request_body["srid"]]
689694
zoom = request_body.get("zoom", None)
690695
except MultiValueDictKeyError:
@@ -695,7 +700,11 @@ def set_thumbnail_from_bbox(self, request, resource_id, *args, **kwargs):
695700
zoom = request_body.get("zoom", None)
696701

697702
thumbnail_url = create_thumbnail(
698-
resource.get_real_instance(), bbox=bbox, background_zoom=zoom, overwrite=True
703+
resource.get_real_instance(),
704+
bbox=bbox,
705+
background_zoom=zoom,
706+
overwrite=True,
707+
map_thumb_from_bbox=map_thumb_from_bbox,
699708
)
700709
return Response(
701710
{"message": "Thumbnail correctly created.", "success": True, "thumbnail_url": thumbnail_url}, status=200

geonode/thumbs/thumbnails.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def create_thumbnail(
6262
styles: Optional[List] = None,
6363
overwrite: bool = False,
6464
background_zoom: Optional[int] = None,
65+
map_thumb_from_bbox: bool = False,
6566
) -> None:
6667
"""
6768
Function generating and saving a thumbnail of the given instance (Dataset or Map), which is composed of
@@ -111,7 +112,7 @@ def create_thumbnail(
111112

112113
if isinstance(instance, Map):
113114
is_map_with_datasets = MapLayer.objects.filter(map=instance, local=True).exclude(dataset=None).exists()
114-
if is_map_with_datasets:
115+
if is_map_with_datasets and not map_thumb_from_bbox:
115116
compute_bbox_from_datasets = True
116117
if bbox:
117118
bbox = bbox_utils.clean_bbox(bbox, target_crs)

0 commit comments

Comments
 (0)