Skip to content

Commit

Permalink
Remove hard dependency on plone.app.relationfield
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Aug 22, 2018
1 parent f8e93c5 commit 27539a4
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -7,9 +7,15 @@ There's a frood who really knows where his towel is.
^^^^^^^^^^^^^^^^^^

.. warning::
This version removes the hard dependency on ``plone.app.relationfield``;
you must use the ``[relations]`` extra if you are using the ``IRelatedItems`` behavior.
Upgrading from versions below 1.2b1 is no longer supported.
You must upgrade at least to version 1.2b1 before upgrading to this release.

- Remove hard dependency on ``plone.app.relationfield``;
if you use the ``IRelatedItems`` behavior you must use the ``[relations]`` extra (closes `#684 <https://github.com/collective/collective.cover/issues/684>`_).
[hvelarde]

- Remove predefined layouts as they were created using Deco grid system and they are broken in Plone 5 (closes `#652 <https://github.com/collective/collective.cover/issues/652>`_).
You can still create your own layouts using your favorite grid system as usually.
[rodfersou]
Expand Down
15 changes: 14 additions & 1 deletion README.rst
Expand Up @@ -110,7 +110,7 @@ Installation

To enable this package in a buildout-based installation:

Edit your buildout.cfg and add add the following to it:
Edit your buildout.cfg and add the following to it:

.. code-block:: ini
Expand Down Expand Up @@ -144,6 +144,19 @@ Check the box next to ``collective.cover`` and click the 'Activate' button.
You may have to empty your browser cache and save your resource registries
in order to see the effects of the product installation.

Content relations
^^^^^^^^^^^^^^^^^

If you want to use the ``IRelatedItems`` behavior you must use the ``[relations]`` extra in your buildout configuration.

.. code-block:: ini
[buildout]
...
eggs =
collective.cover [relations]
Not entirely unlike
-------------------

Expand Down
2 changes: 1 addition & 1 deletion buildout.cfg
Expand Up @@ -5,7 +5,7 @@ extends =
versions-4.3.x.cfg

package-name = collective.cover
package-extras = [test]
package-extras = [relations, test]

parts +=
checkversions
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -50,15 +50,14 @@
'Missing',
'plone.api >=1.4.11',
'plone.app.blocks >=2.2.1',
'plone.app.dexterity [relations]',
'plone.app.dexterity',
'plone.app.iterate',
'plone.app.jquery',
'plone.app.jquerytools',
'plone.app.layout',
'plone.app.linkintegrity',
'plone.app.lockingbehavior',
'plone.app.registry',
'plone.app.relationfield',
'plone.app.textfield',
'plone.app.tiles >=1.1.0',
'plone.app.uuid',
Expand Down Expand Up @@ -91,6 +90,9 @@
'zope.schema',
],
extras_require={
'relations': [
'plone.app.dexterity [relations]',
],
'test': [
'cssselect',
'mock',
Expand Down
1 change: 0 additions & 1 deletion src/collective/cover/configure.zcml
Expand Up @@ -16,7 +16,6 @@
<include package="plone.app.dexterity" />
<include package="plone.app.iterate" />
<include package="plone.app.lockingbehavior" />
<include package="plone.app.relationfield" />
<include package="plone.app.tiles" />

<include package="collective.js.bootstrap" />
Expand Down
1 change: 1 addition & 0 deletions src/collective/cover/profiles.zcml
Expand Up @@ -10,6 +10,7 @@
directory="profiles/default"
description="A sane, working, editor-friendly way of creating front pages and other composite pages. Working now, for mere mortals."
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler="collective.cover.setuphandlers.run_after"
/>

<genericsetup:registerProfile
Expand Down
Expand Up @@ -22,7 +22,6 @@
<element value="plone.app.dexterity.behaviors.metadata.IBasic" />
<element value="plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation" />
<element value="plone.app.lockingbehavior.behaviors.ILocking" />
<element value="plone.app.relationfield.behavior.IRelatedItems" />
</property>

<!-- View information -->
Expand Down
22 changes: 22 additions & 0 deletions src/collective/cover/setuphandlers.py
Expand Up @@ -2,6 +2,16 @@
from Products.CMFPlone.interfaces import INonInstallable
from zope.interface import implementer

import pkg_resources


try:
pkg_resources.get_distribution('plone.app.relationfield')
except pkg_resources.DistributionNotFound:
HAS_RELATIONFIELD = False
else:
HAS_RELATIONFIELD = True


@implementer(INonInstallable)
class HiddenProfiles(object): # pragma: no cover
Expand All @@ -12,3 +22,15 @@ def getNonInstallableProfiles(self):
u'collective.cover:testfixture',
u'collective.cover:uninstall',
]


def add_relationfield_behavior():
"""Add IRelatedItems behavior to FTI."""
from plone import api
fti = api.portal.get_tool('portal_types')['collective.cover.content']
fti.behaviors += ('plone.app.relationfield.behavior.IRelatedItems',)


def run_after(portal_setup):
if HAS_RELATIONFIELD:
add_relationfield_behavior()
2 changes: 2 additions & 0 deletions src/collective/cover/tests/test_cover.py
Expand Up @@ -3,6 +3,7 @@
from collective.cover.config import DEFAULT_GRID_SYSTEM
from collective.cover.controlpanel import ICoverSettings
from collective.cover.interfaces import ICover
from collective.cover.setuphandlers import HAS_RELATIONFIELD
from collective.cover.testing import INTEGRATION_TESTING
from plone import api
from plone.app.dexterity.behaviors.exclfromnav import IExcludeFromNavigation
Expand Down Expand Up @@ -56,6 +57,7 @@ def test_exclude_from_navigation_behavior(self):
def test_locking_behavior(self):
self.assertTrue(ILocking.providedBy(self.cover))

@unittest.skipUnless(HAS_RELATIONFIELD, 'Needs plone.app.relationfield')
def test_relateditems_behavior(self):
from plone.app.relationfield.behavior import IRelatedItems
self.assertTrue(IRelatedItems.providedBy(self.cover))
Expand Down

0 comments on commit 27539a4

Please sign in to comment.