Skip to content

Commit

Permalink
Merge e1e95f2 into f1ad6c7
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Aug 9, 2018
2 parents f1ad6c7 + e1e95f2 commit ce057a6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Expand Up @@ -6,7 +6,10 @@ There's a frood who really knows where his towel is.
1.7b4 (unreleased)
^^^^^^^^^^^^^^^^^^

- Fix edit list element in compose tab on Plone 5.
- Fix retrieval of available image scales in tile layout configuration for Plone 5 (fixes `#781 <https://github.com/collective/collective.cover/issues/781>`_).
[rodfersou]

- Fix edit list element in compose tab on Plone 5 (fixes `#770 <https://github.com/collective/collective.cover/issues/770>`_).
[rodfersou]

- Fix display of tabs in content chooser for Plone 5.
Expand Down
6 changes: 6 additions & 0 deletions src/collective/cover/browser/configure.zcml
Expand Up @@ -78,6 +78,12 @@
permission="zope2.View"
class=".cover.UpdateTile"
/>
<browser:page
name="cover-helper"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
permission="collective.cover.CanEditLayout"
class=".cover.Helper"
/>
<browser:menuItems
for="collective.cover.content.ICover"
menu="plone_displayviews">
Expand Down
17 changes: 17 additions & 0 deletions src/collective/cover/browser/cover.py
Expand Up @@ -2,7 +2,9 @@
from plone.app.blocks.interfaces import IBlocksTransformEnabled
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.component import getUtility
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory


@implementer(IBlocksTransformEnabled)
Expand Down Expand Up @@ -48,3 +50,18 @@ def render(self):
def __call__(self):
self.setup()
return self.render()


class Helper(BrowserView):
"""Helper view used to retrieve image scales on the namedimage
configuration widget.
"""

@staticmethod
def get_image_scales():
"""List all image scales which are available on the site."""
factory = getUtility(
IVocabularyFactory, 'plone.app.vocabularies.ImagesScales')
vocabulary = factory(None)
# TODO: fix scales order upsteam in plone.app.vocabularies
return [term.title for term in vocabulary]
4 changes: 2 additions & 2 deletions src/collective/cover/tests/test_scaling.robot
Expand Up @@ -37,7 +37,7 @@ Test Scaling
Open Layout Tab
Click Config from Tile ${tile_class}
Wait until element is visible id=buttons-cancel
Select From List css=#collective-cover-basic-image-imgsize listing 16:16
Select From List css=#collective-cover-basic-image-imgsize listing 16x16
Click Button id=buttons-save
Save Cover Layout

Expand All @@ -47,7 +47,7 @@ Test Scaling
Open Layout Tab
Click Config from Tile ${tile_class}
Wait until element is visible id=buttons-cancel
Select From List css=#collective-cover-basic-image-imgsize icon 32:32
Select From List css=#collective-cover-basic-image-imgsize icon 32x32
Click Button id=buttons-save
Save Cover Layout

Expand Down
10 changes: 10 additions & 0 deletions src/collective/cover/tests/test_vocabularies.py
Expand Up @@ -133,3 +133,13 @@ def test_grid_systems(self):
self.assertEqual(grids.getTerm('bootstrap3').title, u'Bootstrap 3')
self.assertEqual(grids.getTerm('bootstrap2').title, u'Bootstrap 2')
self.assertEqual(grids.getTerm('deco16_grid').title, u'Deco (16 columns)')

def test_image_scales(self):
from collective.cover.browser.cover import Helper
vocabulary = Helper.get_image_scales()

self.assertGreater(len(vocabulary), 0)
# test against some expected values
self.assertIn(u'imagescale_mini', vocabulary)
self.assertIn(u'imagescale_preview', vocabulary)
self.assertIn(u'imagescale_large', vocabulary)
Expand Up @@ -8,9 +8,8 @@
tal:omit-tag="">

<tal:stored_data define="stored_data python:view.form.getFieldConfiguration(view);
properties view/form/context/@@plone_tools/properties;
imaging_properties properties/imaging_properties;
allowed_sizes python:imaging_properties.getProperty('allowed_sizes')">
portal view/form/context/@@plone_portal_state/portal;
allowed_sizes portal/@@cover-helper/get_image_scales">

<div class="visibility-box">
<span i18n:translate="">Visible</span>
Expand Down Expand Up @@ -86,4 +85,4 @@
</select>

</tal:stored_data>
</html>
</html>

0 comments on commit ce057a6

Please sign in to comment.