Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove portal properties usage #11

Open
wants to merge 3 commits into
base: plone5
Choose a base branch
from
Open
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
40 changes: 15 additions & 25 deletions collective/plonefinder/browser/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import getFSVersionTuple
from plone.app.layout.navigation.interfaces import INavigationRoot
from plone.app.imaging.utils import getAllowedSizes
try:
from Products.ATContentTypes.interface import IATTopic
HAS_AT = True
Expand Down Expand Up @@ -586,33 +586,23 @@ def finderResults(self):

return results


def getThumbSizes(self):
"""Return an ordered list of thumb sizes taken from portal properties
imaging properties when exists list of tuples [(label, width, height,
thumb_label, thumb_extension), ...]
FIXME: This is too much associated with standard ATImage. We should proceed
with views/adapters
"""Return an ordered list of thumb sizes taken from portal imaging settings
(if existing) as list of tuples [(name, width, height,
label, url_appendix), ...]
"""
context = aq_inner(self.context)
pprops = getToolByName(context, 'portal_properties')
if hasattr(pprops, 'imaging_properties'):
imaging_properties = pprops.imaging_properties
thumb_sizes_props = imaging_properties.getProperty('allowed_sizes')
# use util from plone.app.imaging to retrieve the sizes (dict of size tuples)
image_sizes = getAllowedSizes()
if image_sizes:
thumb_sizes = []
for prop in thumb_sizes_props:
propInfo = prop.split(' ')
thumb_name = propInfo[0]
thumb_width = int(propInfo[1].split(':')[0])
thumb_height = int(propInfo[1].split(':')[1])
thumb_label = "%s : %ipx*%ipx" % (_(thumb_name.capitalize()), thumb_width,
thumb_height)
thumb_extension = "/@@images/image/%s" % thumb_name
thumb_sizes.append((thumb_name, thumb_width, thumb_height, thumb_label,
thumb_extension))
thumb_sizes.sort(key=lambda ts: ts[1])
return thumb_sizes

for name in image_sizes:
width, height = image_sizes[name]
label = "%s : %ipx*%ipx" % (_(name.capitalize()), width, height)
url_appendix = "/@@images/image/%s" % name
thumb_sizes.append((name, width, height, label, url_appendix))
return sorted(thumb_sizes, key=lambda ts: ts[1])

# a default
return [
('listing', 16, 16, '%s : 16px*16px' % _('Listing'), '/@@images/image/listing'),
('icon', 32, 32, '%s : 32px*32px' % _('Icon'), '/@@images/image/icon'),
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def read(*names):
# -*- Extra requirements: -*-
'collective.quickupload',
'plone.api',
'plone.app.imaging',
],
entry_points="""
# -*- Entry points: -*-
Expand Down