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
12 changes: 10 additions & 2 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion geonode/resource/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/common/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading