Skip to content

Commit

Permalink
Merge pull request #593 from collective/hvelarde-qa
Browse files Browse the repository at this point in the history
Refactor previous PR
  • Loading branch information
hvelarde committed Mar 1, 2016
2 parents bd9266d + 06ee040 commit 0680721
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 73 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ There's a frood who really knows where his towel is.
1.0a13 (unreleased)
^^^^^^^^^^^^^^^^^^^

- Accept collection and folder objects into carousel tile (closes `574`_).
- You can now use a collection to populate a carousel tile;
search results without a lead image will be bypassed (fixes `#574`_).
[rodfersou]

- Shows message to user if an exception is thrown in a tile (closes `#581`_).
Expand Down
56 changes: 17 additions & 39 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ offer. However, despite offering rich resources to build a cover,
``collective.cover`` also provides a very easy mechanism for managing its
contents, built around a drag-and-drop interface.

``collective.cover`` is based on `Blocks`_ and `Tiles`_, like `Mosaic`_, the new layout solution for Plone.

.. _`Blocks`: https://pypi.python.org/pypi/plone.app.blocks
.. _`Mosaic`: https://pypi.python.org/pypi/plone.app.mosaic
.. _`Tiles`: https://pypi.python.org/pypi/plone.app.tiles
``collective.cover`` is based on `Blocks <https://pypi.python.org/pypi/plone.app.blocks>`_ and `Tiles <https://pypi.python.org/pypi/plone.app.tiles>`_,
like `Mosaic <https://pypi.python.org/pypi/plone.app.mosaic>`_,
the new layout solution for Plone.

Demo
^^^^

For impatient types, there is a demo installation of collective.cover on `Heroku`_.
For impatient types, there is a demo installation of collective.cover on `Heroku <http://collective-cover.herokuapp.com>`_.
It needs about 60 seconds to spin up and it will purge all changes after about an hour of non-usage.

.. _`Heroku`: http://collective-cover.herokuapp.com

Use cases
^^^^^^^^^

Expand Down Expand Up @@ -83,39 +79,29 @@ Mostly Harmless
.. image:: https://img.shields.io/coveralls/collective/collective.cover/master.svg
:target: https://coveralls.io/r/collective/collective.cover

Got an idea? Found a bug? Let us know by `opening a support ticket`_.

.. _`opening a support ticket`: https://github.com/collective/collective.cover/issues
Got an idea? Found a bug? Let us know by `opening a support ticket <https://github.com/collective/collective.cover/issues>`_.

Known issues
^^^^^^^^^^^^

* `Versioning creates zillions of empty blob files`_.
* `Versioning creates zillions of empty blob files <https://github.com/collective/collective.cover/issues/532>`_.
If you're using this feature in your site you have to take special attention to the number of free inodes in your file system,
as you can run out of them;
use the ``df -i`` command to check it.

* `Package is not compatible with standard Plone tiles`_.
* `Package is not compatible with standard Plone tiles <https://github.com/collective/collective.cover/issues/81>`_.
This will be addressed in a future release, if we get an sponsor.

See the `complete list of bugs on GitHub`_.

.. _`Versioning creates zillions of empty blob files`: https://github.com/collective/collective.cover/issues/532
.. _`Package is not compatible with standard Plone tiles`: https://github.com/collective/collective.cover/issues/81
.. _`complete list of bugs on GitHub`: https://github.com/collective/collective.cover/issues?labels=bug&milestone=&page=1&state=open
See the `complete list of bugs on GitHub <https://github.com/collective/collective.cover/issues?labels=bug&milestone=&page=1&state=open>`_.

Don't Panic
-----------

We are currently working on the documentation of the package; this is what we have right now (contributions are always welcomed):

* `Quick Tour video on YouTube`_.
* `End user documentation`_
* `Developer documentation`_

.. _`Developer documentation`: https://github.com/collective/collective.cover/blob/master/docs/developer.rst
.. _`End user documentation`: https://github.com/collective/collective.cover/blob/master/docs/end-user.rst
.. _`Quick Tour video on YouTube`: https://www.youtube.com/watch?v=h_rsSL1e4i4
* `Quick Tour video on YouTube <https://www.youtube.com/watch?v=h_rsSL1e4i4>`_.
* `End user documentation <https://github.com/collective/collective.cover/blob/master/docs/end-user.rst>`_
* `Developer documentation <https://github.com/collective/collective.cover/blob/master/docs/developer.rst>`_

Installation
^^^^^^^^^^^^
Expand Down Expand Up @@ -176,40 +162,32 @@ Over the years there have been some packages designed to solve the problem of
creating section covers in Plone. We have used and have taken ideas from the
following:

`CompositePack`_
`CompositePack <https://pypi.python.org/pypi/Products.CompositePack>`_
Very old; the legacy code is so complex that is not maintainable anymore.
It has (arguably) the best user interface of all. Layouts can not be
created TTW. Viewlets are just page templates associated with content
types; you can drag&drop viewlets around the layout. Publishers love it.

`CMFContentPanels`_
`CMFContentPanels <https://pypi.python.org/pypi/Products.CMFContentPanels>`_
Code is very old, but still maintained (at least works in Plone 4). Allows
to create complex layouts TTW and use any layout as a template. Easy to
extend and edit (but is terrible to find a content to use). Needs a lot of
memory to work and aggressive cache settings.

`Collage`_
`Collage <https://pypi.python.org/pypi/Products.Collage>`_
Allows the creation of layouts TTW but it has (arguably) the worst user
interface of all. It is easily extended and there are several add-ons
available that provide new functionality for it.

`Home Page Editor of the Brazilian Chamber of Deputies Site`_
Strongly based on `Collage`_, this package was presented at the `World Plone Day 2012 Brasilia`_.
`Home Page Editor of the Brazilian Chamber of Deputies Site <https://colab.interlegis.leg.br/browser/publico/camara.home>`_
Strongly based on `Collage`_, this package was presented at the `World Plone Day 2012 Brasilia <http://colab.interlegis.leg.br/wiki/WorldPloneDay>`_.
It allows editing of home pages and the definition of permissions on blocks of content.
Works under Plone 3 only.

`collective.panels`_
`collective.panels <https://pypi.python.org/pypi/collective.panels>`_
A new package that lets site editors add portlets to a set of new
locations: above and below page contents, portal top and footer. The
package comes with a number of flexible layouts that are used to position
the portlets, and locations can be fixed to the nearest site object, to
facilitate inheritance. In ``collective.cover`` (this package), we don't
want to use portlets at all.

.. _`CMFContentPanels`: http://plone.org/products/cmfcontentpanels
.. _`Collage`: http://plone.org/products/collage
.. _`collective.panels`: https://github.com/collective/collective.panels
.. _`CompositePack`: http://plone.org/products/compositepack
.. _`Home Page Editor of the Brazilian Chamber of Deputies Site`: https://colab.interlegis.leg.br/browser/publico/camara.home
.. _`Using tiles to provide more flexible Plone layouts`: http://davisagli.com/blog/using-tiles-to-provide-more-flexible-plone-layouts
.. _`World Plone Day 2012 Brasilia`: http://colab.interlegis.leg.br/wiki/WorldPloneDay
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
'plone.z3cform',
'Products.Archetypes',
'Products.CMFCore',
'Products.CMFPlone >=4.2',
'Products.CMFPlone >=4.2, <5.0',
'Products.GenericSetup',
'setuptools',
'z3c.caching',
Expand Down
21 changes: 21 additions & 0 deletions src/collective/cover/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@
]


zptlogo = (
'GIF89a\x10\x00\x10\x00\xd5\x00\x00\xff\xff\xff\xff\xff\xfe\xfc\xfd\xfd'
'\xfa\xfb\xfc\xf7\xf9\xfa\xf5\xf8\xf9\xf3\xf6\xf8\xf2\xf5\xf7\xf0\xf4\xf6'
'\xeb\xf1\xf3\xe5\xed\xef\xde\xe8\xeb\xdc\xe6\xea\xd9\xe4\xe8\xd7\xe2\xe6'
'\xd2\xdf\xe3\xd0\xdd\xe3\xcd\xdc\xe1\xcb\xda\xdf\xc9\xd9\xdf\xc8\xd8\xdd'
'\xc6\xd7\xdc\xc4\xd6\xdc\xc3\xd4\xda\xc2\xd3\xd9\xc1\xd3\xd9\xc0\xd2\xd9'
'\xbd\xd1\xd8\xbd\xd0\xd7\xbc\xcf\xd7\xbb\xcf\xd6\xbb\xce\xd5\xb9\xcd\xd4'
'\xb6\xcc\xd4\xb6\xcb\xd3\xb5\xcb\xd2\xb4\xca\xd1\xb2\xc8\xd0\xb1\xc7\xd0'
'\xb0\xc7\xcf\xaf\xc6\xce\xae\xc4\xce\xad\xc4\xcd\xab\xc3\xcc\xa9\xc2\xcb'
'\xa8\xc1\xca\xa6\xc0\xc9\xa4\xbe\xc8\xa2\xbd\xc7\xa0\xbb\xc5\x9e\xba\xc4'
'\x9b\xbf\xcc\x98\xb6\xc1\x8d\xae\xbaFgs\x00\x00\x00\x00\x00\x00\x00\x00'
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
'\x00,\x00\x00\x00\x00\x10\x00\x10\x00\x00\x06z@\x80pH,\x12k\xc8$\xd2f\x04'
'\xd4\x84\x01\x01\xe1\xf0d\x16\x9f\x80A\x01\x91\xc0ZmL\xb0\xcd\x00V\xd4'
'\xc4a\x87z\xed\xb0-\x1a\xb3\xb8\x95\xbdf8\x1e\x11\xca,MoC$\x15\x18{'
'\x006}m\x13\x16\x1a\x1f\x83\x85}6\x17\x1b $\x83\x00\x86\x19\x1d!%)\x8c'
'\x866#\'+.\x8ca`\x1c`(,/1\x94B5\x19\x1e"&*-024\xacNq\xba\xbb\xb8h\xbeb'
'\x00A\x00;'
)


def loadFile(name, size=0):
"""Load file from testing directory
"""
Expand Down
4 changes: 1 addition & 3 deletions src/collective/cover/tests/test_basic_tile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from collective.cover.testing import ALL_CONTENT_TYPES
from collective.cover.config import PLONE_VERSION
from collective.cover.testing import generate_jpeg
from collective.cover.testing import images_are_equal
from collective.cover.tests.base import TestTileMixin
Expand Down Expand Up @@ -230,11 +229,10 @@ def test_basic_tile_image(self):

self.assertIn('test/@@images', rendered)

@unittest.skipIf(PLONE_VERSION < '4.3', 'zptlogo not available')
def test_double_assign_tile_dexterity_image(self):
# https://github.com/collective/collective.cover/issues/449
from collective.cover.testing import zptlogo
from plone.namedfile.file import NamedBlobImage
from plone.namedfile.tests.test_image import zptlogo
with api.env.adopt_roles(['Manager']):
obj = api.content.create(self.portal, 'Dexterity Image', 'foo')
obj.image = NamedBlobImage(zptlogo)
Expand Down
30 changes: 5 additions & 25 deletions src/collective/cover/tests/test_carousel_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@
import unittest


zptlogo = (
'GIF89a\x10\x00\x10\x00\xd5\x00\x00\xff\xff\xff\xff\xff\xfe\xfc\xfd\xfd'
'\xfa\xfb\xfc\xf7\xf9\xfa\xf5\xf8\xf9\xf3\xf6\xf8\xf2\xf5\xf7\xf0\xf4\xf6'
'\xeb\xf1\xf3\xe5\xed\xef\xde\xe8\xeb\xdc\xe6\xea\xd9\xe4\xe8\xd7\xe2\xe6'
'\xd2\xdf\xe3\xd0\xdd\xe3\xcd\xdc\xe1\xcb\xda\xdf\xc9\xd9\xdf\xc8\xd8\xdd'
'\xc6\xd7\xdc\xc4\xd6\xdc\xc3\xd4\xda\xc2\xd3\xd9\xc1\xd3\xd9\xc0\xd2\xd9'
'\xbd\xd1\xd8\xbd\xd0\xd7\xbc\xcf\xd7\xbb\xcf\xd6\xbb\xce\xd5\xb9\xcd\xd4'
'\xb6\xcc\xd4\xb6\xcb\xd3\xb5\xcb\xd2\xb4\xca\xd1\xb2\xc8\xd0\xb1\xc7\xd0'
'\xb0\xc7\xcf\xaf\xc6\xce\xae\xc4\xce\xad\xc4\xcd\xab\xc3\xcc\xa9\xc2\xcb'
'\xa8\xc1\xca\xa6\xc0\xc9\xa4\xbe\xc8\xa2\xbd\xc7\xa0\xbb\xc5\x9e\xba\xc4'
'\x9b\xbf\xcc\x98\xb6\xc1\x8d\xae\xbaFgs\x00\x00\x00\x00\x00\x00\x00\x00'
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
'\x00,\x00\x00\x00\x00\x10\x00\x10\x00\x00\x06z@\x80pH,\x12k\xc8$\xd2f\x04'
'\xd4\x84\x01\x01\xe1\xf0d\x16\x9f\x80A\x01\x91\xc0ZmL\xb0\xcd\x00V\xd4'
'\xc4a\x87z\xed\xb0-\x1a\xb3\xb8\x95\xbdf8\x1e\x11\xca,MoC$\x15\x18{'
'\x006}m\x13\x16\x1a\x1f\x83\x85}6\x17\x1b $\x83\x00\x86\x19\x1d!%)\x8c'
'\x866#\'+.\x8ca`\x1c`(,/1\x94B5\x19\x1e"&*-024\xacNq\xba\xbb\xb8h\xbeb'
'\x00A\x00;'
)


class CarouselTileTestCase(TestTileMixin, unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -256,22 +235,23 @@ def test_get_alt(self):
self.assertIn(
'alt="This image was created for testing purposes"', rendered)

def test_populate_collection(self):
def test_populate_with_collection(self):
from collective.cover.testing import zptlogo
with api.env.adopt_roles(['Manager']):
api.content.create(
self.portal, 'News Item', id='new1', image=zptlogo)
api.content.create(
self.portal, 'News Item', id='new2', image=zptlogo)
api.content.create(
self.portal, 'News Item', id='new3')
api.content.create(self.portal, 'News Item', id='new3')

query = [dict(
i='portal_type',
o='plone.app.querystring.operation.selection.is',
v='News Item',
)]
col = api.content.create(
self.portal, 'Collection', 'collection', query=query)
api.content.transition(col, 'publish')

self.tile.populate_with_object(col)
rendered = self.tile()
self.assertIn(u'<img src="http://nohost/plone/new1', rendered)
Expand Down
6 changes: 2 additions & 4 deletions src/collective/cover/tiles/carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ def populate_with_object(self, obj):
"""
super(ListTile, self).populate_with_object(obj) # check permission
uuids = ICoverUIDsProvider(obj).getUIDs()
# Accept just elements with image
uuids = [
uuid for uuid in uuids
if self._has_image_field(uuidToObject(uuid))]
# accept just elements with a lead image
uuids = [i for i in uuids if self._has_image_field(uuidToObject(i))]
if uuids:
self.populate_with_uuids(uuids)

Expand Down

0 comments on commit 0680721

Please sign in to comment.