Skip to content

Commit

Permalink
fix compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Feb 6, 2024
1 parent 99dcc0e commit 7a93a2d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
27 changes: 26 additions & 1 deletion src/rer/solrpush/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,32 @@ def restrictedTraverse(self, name):

@property
def image_scales(self):
return json.loads(self.get("image_scales", "{}"))
scales = json.loads(self.get("image_scales", "{}"))
if scales:
return scales

# backward compatibility with < Plone6 indexed contents
if not self.get("getIcon", False):
return {}

return {
"image": [
{
"download": "@@images/image",
"scales": {
"preview": {
"download": "@@images/image/preview",
},
"thumb": {
"download": "@@images/image/thumb",
},
"mini": {
"download": "@@images/image/mini",
},
},
}
]
}


class SolrResults(list):
Expand Down
10 changes: 9 additions & 1 deletion src/rer/solrpush/utils/solr_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,17 @@ def create_index_dict(item):
else:
index_me["url"] = item.absolute_url()

has_image = getattr(item.aq_base, "image", None)
# backward compatibility with Plone < 6 where there wasn't image_field and image_scales indexers
has_image = False
if index_me.get("image_field", None) and index_me.get(
"image_scales", None
):
has_image = True
else:
has_image = getattr(item.aq_base, "image", None)
if has_image:
index_me["getIcon"] = True

return index_me


Expand Down

0 comments on commit 7a93a2d

Please sign in to comment.