diff --git a/geonode/base/models.py b/geonode/base/models.py index d5469477d78..c54112e6e33 100644 --- a/geonode/base/models.py +++ b/geonode/base/models.py @@ -969,8 +969,16 @@ def can_have_wps_links(self): def can_have_style(self): return self.subtype not in {"tileStore", "remote"} - @property - def can_have_thumbnail(self): + def can_set_thumbnail(self, thumbnail_data=None): + """ + Decide whether the resource allows setting a thumbnail. + Manual uploads are allowed; otherwise, only subtypes that + support auto-generated thumbnails are permitted. + """ + if thumbnail_data: + return True + + # No thumbnail data provided: allow only subtypes that support auto-generation. return self.subtype not in {"3dtiles", "cog", "flatgeobuf"} @property diff --git a/geonode/resource/manager.py b/geonode/resource/manager.py index f06879eec91..5c0b3fdd8f6 100644 --- a/geonode/resource/manager.py +++ b/geonode/resource/manager.py @@ -959,7 +959,7 @@ def set_thumbnail( map_thumb_from_bbox: bool = False, ) -> bool: _resource = instance or BaseResourceManager._get_instance(uuid) - if _resource and _resource.can_have_thumbnail: + if _resource and _resource.can_set_thumbnail(thumbnail): try: with transaction.atomic(): if thumbnail: diff --git a/geonode/upload/handlers/common/remote.py b/geonode/upload/handlers/common/remote.py index 34d5cfeccc1..04d9487b8a9 100755 --- a/geonode/upload/handlers/common/remote.py +++ b/geonode/upload/handlers/common/remote.py @@ -220,7 +220,7 @@ def create_geonode_resource( defaults=self.generate_resource_payload(layer_name, alternate, asset, _exec, None, **params), ) # The thumbnail is not created for the following data types: "3dtiles", "cog", "flatgeobuf" - # because of the can_have_thumbnail property + # because of the can_set_thumbnail method resource_manager_registry.get_for_instance(resource).set_thumbnail(None, instance=resource) resource = self.create_link(resource, params, alternate)