Skip to content

Commit

Permalink
Merge pull request #524 from plone/collection-lead-image-master
Browse files Browse the repository at this point in the history
Support ILeadImage behavior when display collections
  • Loading branch information
mauritsvanrees authored Jun 14, 2019
2 parents 9e26cb6 + a7151ac commit faed5de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
5 changes: 2 additions & 3 deletions news/522.bugfix
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- Use the shared 'Plone test setup' and 'Plone test teardown' keywords in Robot
tests.
[Rotonen]
Use the shared 'Plone test setup' and 'Plone test teardown' keywords in Robot tests.
[Rotonen]
2 changes: 2 additions & 0 deletions news/524.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support ILeadImage behavior when display collection album view.
[rodfersou]
8 changes: 5 additions & 3 deletions plone/app/contenttypes/browser/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from Acquisition import aq_inner
from plone.app.contenttypes import _
from plone.app.contenttypes.behaviors.collection import ICollection
from plone.app.contenttypes.behaviors.leadimage import ILeadImage
from plone.app.contenttypes.browser.folder import FolderView
from plone.app.contenttypes.interfaces import IFolder
from plone.app.contenttypes.interfaces import IImage
Expand Down Expand Up @@ -56,10 +57,11 @@ def _album_results(self):
for it in results:
# TODO: potentially expensive!
ob = it.getObject()
if IImage.providedBy(ob):
images.append(it)
elif IFolder.providedBy(ob):
if IFolder.providedBy(ob):
folders.append(it)
elif IImage.providedBy(ob) or \
ILeadImage.providedBy(ob):
images.append(it)
return {'images': images, 'folders': folders}

@property
Expand Down
9 changes: 7 additions & 2 deletions plone/app/contenttypes/browser/folder.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
from Acquisition import aq_inner
from Products.CMFPlone.interfaces import ISiteSchema
from plone.app.contenttypes import _
from plone.app.contenttypes.behaviors.leadimage import ILeadImage
from plone.app.contenttypes.interfaces import IFolder
from plone.app.contenttypes.interfaces import IImage
from plone.event.interfaces import IEvent
from plone.memoize.view import memoize
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces import ISiteSchema
from Products.CMFPlone.PloneBatch import Batch
from Products.CMFPlone.utils import safe_callable
from Products.Five import BrowserView
Expand Down Expand Up @@ -207,9 +208,13 @@ def formatted_date(self, item):
def album_images(self):
"""Get all images within this folder.
"""
provides = [
IImage.__identifier__,
ILeadImage.__identifier__,
]
images = self.results(
batch=False,
object_provides=IImage.__identifier__
object_provides=provides
)
return images

Expand Down
6 changes: 4 additions & 2 deletions plone/app/contenttypes/browser/templates/listing_album.pt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
tal:define="portal context/@@plone_portal_state/portal;
image_scale portal/@@image_scale">
<tal:images tal:repeat="image images">
<div class="photoAlbumEntry">
<div class="photoAlbumEntry"
tal:define="scale python:image_scale.tag(image, 'image', scale='thumb')"
tal:condition="scale">
<a tal:attributes="href string:${image/getURL}/view;
title image/Description">
<span class="photoAlbumEntryWrapper">
<img tal:replace="structure python:image_scale.tag(image, 'image', scale='thumb')" />
<img tal:replace="structure scale" />
</span>
<span class="photoAlbumEntryTitle" tal:content="image/Title">
Title
Expand Down
6 changes: 4 additions & 2 deletions plone/app/contenttypes/tests/robot/test_folderlisting.robot
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ Listing should list all content in detail

Album should list all images and albums
Page Should Contain Test Image
Xpath Should Match X Times //img[@title="Test Image"] 3
Xpath Should Match X Times //div[@class="photoAlbumEntry" and not(@class="photoAlbumFolder")]//img[@title="Test Image"] 1
Page Should Contain Test News Item
Xpath Should Match X Times //div[@class="photoAlbumEntry" and not(@class="photoAlbumFolder")]//img[@title="Test News Item"] 1
Page Should Contain Test Album Image 1
Xpath Should Match X Times //div[@class="photoAlbumEntry" and not(@class="photoAlbumFolder")]//img[@title="Test Album Image 1"] 1
Page Should Contain Test Album Image 2
Expand All @@ -176,7 +178,7 @@ Album should list all images and albums
Xpath Should Match X Times //div[@class="photoAlbumEntry" and not(@class="photoAlbumFolder")]//img[@title="Test Sub Album Image 3"] 1
Page Should Contain Test Album
Page Should Contain Test Sub Album

Page Should Contain Test Folder


Setup Testcontent
Expand Down

0 comments on commit faed5de

Please sign in to comment.