Skip to content

Commit

Permalink
Disable calendar tile in Plone 5
Browse files Browse the repository at this point in the history
Refs. #633
  • Loading branch information
hvelarde committed Aug 18, 2016
1 parent 84450f9 commit d22f003
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 33 deletions.
10 changes: 10 additions & 0 deletions src/collective/cover/tests/test_calendar_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ def test_default_configuration(self):

def test_accepted_content_types(self):
self.assertEqual(self.tile.accepted_ct(), [])


# load tests only in Plone < 5
def test_suite():
# FIXME: https://github.com/collective/collective.cover/issues/633
from collective.cover.config import IS_PLONE_5
if IS_PLONE_5:
return unittest.TestSuite()

return unittest.defaultTestLoader.loadTestsFromName(__name__)
2 changes: 2 additions & 0 deletions src/collective/cover/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ def test_registrations(self):
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 4)

# FIXME: https://github.com/collective/collective.cover/issues/633
@unittest.skipIf(IS_PLONE_5, 'Upgrade step not supported under Plone 5')
def test_register_calendar_tile(self):
# address also an issue with Setup permission
title = u'Register calendar tile'
Expand Down
69 changes: 42 additions & 27 deletions src/collective/cover/tests/test_vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

from collective.cover.config import IS_PLONE_5
from collective.cover.controlpanel import ICoverSettings
from collective.cover.testing import INTEGRATION_TESTING
from plone.registry.interfaces import IRegistry
Expand Down Expand Up @@ -33,38 +33,53 @@ def test_available_tiles_vocabulary(self):
vocabulary = queryUtility(IVocabularyFactory, name)
self.assertIsNotNone(vocabulary)
tiles = vocabulary(self.portal)
self.assertEqual(len(tiles), 10)
self.assertIn(u'collective.cover.banner', tiles)
self.assertIn(u'collective.cover.basic', tiles)
self.assertIn(u'collective.cover.carousel', tiles)
self.assertIn(u'collective.cover.collection', tiles)
self.assertIn(u'collective.cover.contentbody', tiles)
self.assertIn(u'collective.cover.embed', tiles)
self.assertIn(u'collective.cover.file', tiles)
self.assertIn(u'collective.cover.list', tiles)
self.assertIn(u'collective.cover.richtext', tiles)
expected = [
'collective.cover.banner',
'collective.cover.basic',
'collective.cover.calendar',
'collective.cover.carousel',
'collective.cover.collection',
'collective.cover.contentbody',
'collective.cover.embed',
'collective.cover.file',
'collective.cover.list',
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)

def test_enabled_tiles_vocabulary(self):
name = 'collective.cover.EnabledTiles'
vocabulary = queryUtility(IVocabularyFactory, name)
self.assertIsNotNone(vocabulary)
tiles = vocabulary(self.portal)
self.assertEqual(len(tiles), 11)
self.assertIn(u'collective.cover.banner', tiles)
self.assertIn(u'collective.cover.basic', tiles)
self.assertIn(u'collective.cover.carousel', tiles)
self.assertIn(u'collective.cover.collection', tiles)
self.assertIn(u'collective.cover.contentbody', tiles)
self.assertIn(u'collective.cover.embed', tiles)
self.assertIn(u'collective.cover.file', tiles)
self.assertIn(u'collective.cover.list', tiles)
self.assertIn(u'collective.cover.richtext', tiles)
# FIXME see: https://github.com/collective/collective.cover/issues/194
self.assertIn(u'collective.cover.pfg', tiles)
# XXX: https://github.com/collective/collective.cover/issues/81
# standard tiles are not enabled... yet
self.assertNotIn(u'plone.app.imagetile', tiles)
self.assertNotIn(u'plone.app.texttile', tiles)
expected = [
'collective.cover.banner',
'collective.cover.basic',
'collective.cover.calendar',
'collective.cover.carousel',
'collective.cover.collection',
'collective.cover.contentbody',
'collective.cover.embed',
'collective.cover.file',
'collective.cover.list',
'collective.cover.pfg', # FIXME: https://github.com/collective/collective.cover/issues/194
'collective.cover.richtext',
]

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5:
expected.remove('collective.cover.calendar')

self.assertEqual(len(tiles), len(expected))
for i in expected:
self.assertIn(i, tiles)

def test_available_content_types_vocabulary(self):
name = 'collective.cover.AvailableContentTypes'
Expand Down
19 changes: 13 additions & 6 deletions src/collective/cover/vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

from collective.cover.config import IS_PLONE_5
from collective.cover.controlpanel import ICoverSettings
from collective.cover.interfaces import IGridSystem
from collective.cover.tiles.base import IPersistentCoverTile
Expand Down Expand Up @@ -33,9 +33,12 @@ class AvailableTilesVocabulary(object):
def __call__(self, context):

registry = getUtility(IRegistry)
tiles = registry[
'collective.cover.controlpanel.ICoverSettings.available_tiles'
]
settings = registry.forInterface(ICoverSettings)
tiles = settings.available_tiles

# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5 and 'collective.cover.calendar' in tiles:
tiles.remove('collective.cover.calendar')

items = [SimpleTerm(value=i, title=i) for i in tiles]
return SimpleVocabulary(items)
Expand All @@ -52,10 +55,14 @@ def __call__(self, context):

@implementer(IVocabularyFactory)
class EnabledTilesVocabulary(object):
"""Return a list of tiles ready to work with collective.cover.
"""

"""Return a list of tiles ready to work with collective.cover."""

def _enabled(self, name):
# FIXME: https://github.com/collective/collective.cover/issues/633
if IS_PLONE_5 and name == 'collective.cover.calendar':
return False

tile_type = queryUtility(ITileType, name)
if tile_type:
return issubclass(tile_type.schema, IPersistentCoverTile)
Expand Down

0 comments on commit d22f003

Please sign in to comment.