From 3cfc044ad8061907967fe84b2c638461e93e7ce5 Mon Sep 17 00:00:00 2001 From: Franz Gerhard Reinisch Date: Sat, 10 Oct 2015 11:44:49 +0200 Subject: [PATCH] Cleanup and rework: contenttype-icons and showing thumbnails for images/leadimages in listings ... https://github.com/plone/Products.CMFPlone/issues/1226 https://github.com/plone/Products.CMFPlone/issues/1185 --- CHANGES.rst | 7 +++ plone/app/contenttypes/browser/folder.py | 6 -- .../contenttypes/browser/templates/listing.pt | 22 ++++--- .../browser/templates/listing_tabular.pt | 6 ++ plone/app/contenttypes/indexers.py | 61 +++++-------------- plone/app/contenttypes/indexers.zcml | 3 +- plone/app/contenttypes/tests/test_indexes.py | 30 --------- 7 files changed, 41 insertions(+), 94 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e78d190e1..3d0e07dbb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -30,6 +30,13 @@ Fixes: [pbauer] - Fixed full_view when content is not IUUIDAware (like the portal). + +- Cleanup and rework: contenttype-icons + and showing thumbnails for images/leadimages in listings ... + https://github.com/plone/Products.CMFPlone/issues/1226 + [fgrcon] + +- Fix full_view when content is not IUUIDAware (like the portal). Fixes https://github.com/plone/Products.CMFPlone/issues/1109. [pbauer] diff --git a/plone/app/contenttypes/browser/folder.py b/plone/app/contenttypes/browser/folder.py index b53d41171..50b5c3390 100644 --- a/plone/app/contenttypes/browser/folder.py +++ b/plone/app/contenttypes/browser/folder.py @@ -155,12 +155,6 @@ def tabular_fielddata(self, item, fieldname): 'value': value } - def has_image(self, obj): - if getattr(obj, 'getObject', False): - obj = obj.getObject() - img = getattr(aq_base(obj), 'image', None) - return True if img else False - def is_event(self, obj): if getattr(obj, 'getObject', False): obj = obj.getObject() diff --git a/plone/app/contenttypes/browser/templates/listing.pt b/plone/app/contenttypes/browser/templates/listing.pt index 24ffd7353..1c7bbaf00 100644 --- a/plone/app/contenttypes/browser/templates/listing.pt +++ b/plone/app/contenttypes/browser/templates/listing.pt @@ -31,23 +31,25 @@ item_type item/PortalType; item_modified item/ModificationDate; item_created item/CreationDate; - item_icon item/getIcon; item_type_class python:'contenttype-' + view.normalizeString(item_type); item_wf_state item/review_state; item_wf_state_class python:'state-' + view.normalizeString(item_wf_state); item_creator item/Creator; - item_link python:item_type in view.use_view_action and item_url+'/view' or item_url; - item_has_image python:view.has_image(obj); - item_is_event python:view.is_event(obj)"> + item_link python:item_type in view.use_view_action and item_url+'/view' or item_url; + item_is_event python:view.is_event(obj); + item_has_image python:item.getIcon">
- - - Item Title + + + + + Item Title diff --git a/plone/app/contenttypes/browser/templates/listing_tabular.pt b/plone/app/contenttypes/browser/templates/listing_tabular.pt index ab1d18e75..684b3d638 100644 --- a/plone/app/contenttypes/browser/templates/listing_tabular.pt +++ b/plone/app/contenttypes/browser/templates/listing_tabular.pt @@ -55,6 +55,12 @@ + 5.0 + see https://github.com/plone/Products.CMFPlone/issues/1226 + + reuse of metadata field, + now used for showing thumbs in content listings etc. + when obj is an image or has a lead image + or has an image field with name 'image': true else false + ''' + if obj.image: + return True + return False diff --git a/plone/app/contenttypes/indexers.zcml b/plone/app/contenttypes/indexers.zcml index a25ad8b0a..6f8e1673e 100644 --- a/plone/app/contenttypes/indexers.zcml +++ b/plone/app/contenttypes/indexers.zcml @@ -13,7 +13,6 @@ - - + diff --git a/plone/app/contenttypes/tests/test_indexes.py b/plone/app/contenttypes/tests/test_indexes.py index 3c1e17d89..5824c3e94 100644 --- a/plone/app/contenttypes/tests/test_indexes.py +++ b/plone/app/contenttypes/tests/test_indexes.py @@ -298,33 +298,3 @@ def test_getobjsize_file(self): self.portal.getObjSize(None, primary_field_info.value.size), brains[0].getObjSize, ) - - def test_geticon_image(self): - from .test_image import dummy_image - - primary_field_info = IPrimaryFieldInfo(self.image) - primary_field_info.field.set(self.image, dummy_image()) - self.image.reindexObject() - - brains = self.catalog.searchResults(dict( - path="/plone/folder/image", - )) - - self.assertEqual('image.png', brains[0].getIcon) - - def test_geticon_file(self): - from plone.namedfile.file import NamedBlobFile - - filename = os.path.join(os.path.dirname(__file__), u'file.pdf') - test_file = NamedBlobFile(data=open(filename, 'r').read(), - filename=filename) - - primary_field_info = IPrimaryFieldInfo(self.file) - primary_field_info.field.set(self.file, test_file) - self.file.reindexObject() - - brains = self.catalog.searchResults(dict( - path="/plone/folder/file", - )) - - self.assertEqual('pdf.png', brains[0].getIcon)