From 70dd8a036baaf38f2742caff273fb047f3cd7b13 Mon Sep 17 00:00:00 2001 From: Fulvio Casali Date: Tue, 8 Oct 2013 17:35:44 -0300 Subject: [PATCH] Issue #301 - Remove code from Image and Link tiles --- .../profiles/upgrade_2_to_3/registry.xml | 6 +- src/collective/cover/static/tile-image.png | Bin 443 -> 0 bytes src/collective/cover/static/tile-link.png | Bin 655 -> 0 bytes src/collective/cover/tests/test_image_tile.py | 83 --------------- src/collective/cover/tests/test_link_tile.py | 65 ------------ src/collective/cover/tests/test_tiles.py | 1 - src/collective/cover/tiles/image.py | 97 ------------------ src/collective/cover/tiles/link.py | 96 ----------------- src/collective/cover/tiles/templates/image.pt | 38 ------- src/collective/cover/tiles/templates/link.pt | 50 --------- src/collective/cover/tiles/tiles.zcml | 24 ----- 11 files changed, 1 insertion(+), 459 deletions(-) delete mode 100644 src/collective/cover/static/tile-image.png delete mode 100644 src/collective/cover/static/tile-link.png delete mode 100644 src/collective/cover/tests/test_image_tile.py delete mode 100644 src/collective/cover/tests/test_link_tile.py delete mode 100644 src/collective/cover/tiles/image.py delete mode 100644 src/collective/cover/tiles/link.py delete mode 100644 src/collective/cover/tiles/templates/image.pt delete mode 100644 src/collective/cover/tiles/templates/link.pt diff --git a/src/collective/cover/profiles/upgrade_2_to_3/registry.xml b/src/collective/cover/profiles/upgrade_2_to_3/registry.xml index 97a6afa2d..1418125b8 100644 --- a/src/collective/cover/profiles/upgrade_2_to_3/registry.xml +++ b/src/collective/cover/profiles/upgrade_2_to_3/registry.xml @@ -9,12 +9,10 @@ collective.cover.contentbody collective.cover.embed collective.cover.file - collective.cover.image - collective.cover.link collective.cover.list collective.cover.richtext - This tiles will be available for layout creation. + These tiles will be available for layout creation. False Available tiles @@ -28,8 +26,6 @@ collective.cover.contentbody collective.cover.embed collective.cover.file - collective.cover.image - collective.cover.link collective.cover.list collective.cover.richtext diff --git a/src/collective/cover/static/tile-image.png b/src/collective/cover/static/tile-image.png deleted file mode 100644 index 303d686aaef821de52be51a1d72b0ac9fb6a28c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 443 zcmV;s0Yv_ZP)1-D+EhTb9MD)t$$Z1Pda8n_Rq%(rQtBwTO<#ybBfw>Q=ISAG<)KrMFnO({ zp#f08Xq~3&AI6WW}EkpLabh@8r!r9Pku};`yyeoQ0 zI=c~=dEQd!zj-|qYRk3f&I^F1p$wjqejQi=x~Kl#DCP|0K6BoOQl5%;P(K9c4>EqB l%6XWIr+-HO7Qjt_0RWKZZ(vZuvG@Q0002ovPDHLkV1l6lza;)>Voh4#tnC!Fri08+9M6Hydo`0i|?J-H|^CC-d7iO0LUmCN=e5s zT0(cE9nz3ACS~I}=|l(QC;()fy@No zU-JesAm{*2MIteK-lowY{6EYE0+73;AVz74+9FK7?oIOBrV2JLwNHja)VU|6=xo!_rTHY%?+Abn#8c8T zkke`dP~t!vh(ICkn)b{{mtg%^28hTy0Vu$M!~&qu07?PI!=$XocYwZP2Y|B4rK#3b zUaloM#=sJ7IKVA9KufljSK~W$!B}d^ZUBImK}<1{o8-eXE4V!0OfB1XAINlbU2{dt z6jF*h@0f}w-H2u&SAEseHKe6PzFOw8@l)@FF}w_s_fMq?GU>`D05m__rBn&`1L`_b pLe79zrfKN};QG(#-vRg&U;xU18HEsI#1;Sm002ovPDHLkV1ksA9=rem diff --git a/src/collective/cover/tests/test_image_tile.py b/src/collective/cover/tests/test_image_tile.py deleted file mode 100644 index 930686d22..000000000 --- a/src/collective/cover/tests/test_image_tile.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- - -from collective.cover.testing import INTEGRATION_TESTING -from collective.cover.tiles.base import IPersistentCoverTile -from collective.cover.tiles.image import ImageTile -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID -from zope.interface.verify import verifyClass -from zope.interface.verify import verifyObject - -import unittest - - -class ImageTileTestCase(unittest.TestCase): - - layer = INTEGRATION_TESTING - - def setUp(self): - self.portal = self.layer['portal'] - self.request = self.layer['request'] - self.tile = self.portal.restrictedTraverse( - '@@{0}/{1}'.format('collective.cover.image', 'test-image-tile')) - - def test_interface(self): - self.assertTrue(IPersistentCoverTile.implementedBy(ImageTile)) - self.assertTrue(verifyClass(IPersistentCoverTile, ImageTile)) - - tile = ImageTile(None, None) - self.assertTrue(IPersistentCoverTile.providedBy(tile)) - self.assertTrue(verifyObject(IPersistentCoverTile, tile)) - - def test_default_configuration(self): - self.assertTrue(self.tile.is_configurable) - self.assertTrue(self.tile.is_editable) - self.assertTrue(self.tile.is_droppable) - - def test_accepted_content_types(self): - self.assertEqual(self.tile.accepted_ct(), ['Image']) - - def test_render_empty(self): - self.assertIn( - "Drag&drop an image here to populate the tile.", self.tile()) - - def test_render(self): - obj = self.portal['my-image'] - self.tile.populate_with_object(obj) - rendered = self.tile() - self.assertIn('src="http://nohost/plone/my-image/@@images', rendered) - - def test_render_deleted_object(self): - obj = self.portal['my-image'] - self.tile.populate_with_object(obj) - # delete original object - setRoles(self.portal, TEST_USER_ID, ['Manager']) - self.portal.manage_delObjects(['my-image']) - rendered = self.tile() - # no image is rendered - self.assertNotIn('src="http://nohost/plone/my-image/@@images', rendered) - - @unittest.expectedFailure - def test_alt_atribute_present_in_image(self): - """Object's title must be displayed in image alt attribute. - See: https://github.com/collective/collective.cover/issues/182 - """ - obj = self.portal['my-image'] - self.tile.populate_with_object(obj) - rendered = self.tile() - self.assertIn('alt="Test image"', rendered) - - def test_change_images(self): - obj = self.portal['my-image'] - obj1 = self.portal['my-image1'] - self.tile.populate_with_object(obj) - rendered = self.tile() - # the tile renders the image - self.assertIn('src="http://nohost/plone/my-image/@@images', rendered) - # instantiate the tile again - self.tile = self.portal.restrictedTraverse( - '@@{0}/{1}'.format('collective.cover.image', 'test-image-tile')) - self.tile.populate_with_object(obj1) - rendered = self.tile() - # the tile renders the new image - self.assertIn('src="http://nohost/plone/my-image1/@@images', rendered) diff --git a/src/collective/cover/tests/test_link_tile.py b/src/collective/cover/tests/test_link_tile.py deleted file mode 100644 index b1d9217dd..000000000 --- a/src/collective/cover/tests/test_link_tile.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- - -from collective.cover.testing import INTEGRATION_TESTING -from collective.cover.tiles.base import IPersistentCoverTile -from collective.cover.tiles.link import LinkTile -from zope.interface.verify import verifyClass -from zope.interface.verify import verifyObject - -import unittest - - -class LinkTileTestCase(unittest.TestCase): - - layer = INTEGRATION_TESTING - - def setUp(self): - self.portal = self.layer['portal'] - self.request = self.layer['request'] - self.tile = self.portal.restrictedTraverse( - '@@{0}/{1}'.format('collective.cover.link', 'test-link-tile')) - - def test_interface(self): - self.assertTrue(IPersistentCoverTile.implementedBy(LinkTile)) - self.assertTrue(verifyClass(IPersistentCoverTile, LinkTile)) - - tile = LinkTile(None, None) - self.assertTrue(IPersistentCoverTile.providedBy(tile)) - self.assertTrue(verifyObject(IPersistentCoverTile, tile)) - - def test_default_configuration(self): - self.assertFalse(self.tile.is_configurable) - self.assertTrue(self.tile.is_editable) - self.assertTrue(self.tile.is_droppable) - - def test_accepted_content_types(self): - self.assertEqual(self.tile.accepted_ct(), - ['Link', ]) - - def test_populate_with_object(self): - self.tile.populate_with_object(self.portal['my-link']) - self.assertEqual('Test link', self.tile.data['title']) - self.assertEqual("This link was created for testing purposes", - self.tile.data['description']) - - def test_render_empty(self): - self.assertTrue( - "Please drag&drop a link here to populate the tile." in self.tile()) - - def test_render(self): - obj = self.portal['my-link'] - self.tile.populate_with_object(obj) - rendered = self.tile() - self.assertTrue('Test link' in rendered) - self.assertTrue( - "This link was created for testing purposes" in rendered) - - @unittest.expectedFailure - def test_alt_atribute_present_in_image(self): - """Object's title must be displayed in image alt attribute. - See: https://github.com/collective/collective.cover/issues/182 - """ - obj = self.portal['my-link'] - self.tile.populate_with_object(obj) - rendered = self.tile() - self.assertIn('alt="Test link"', rendered) diff --git a/src/collective/cover/tests/test_tiles.py b/src/collective/cover/tests/test_tiles.py index eea16359b..7e9575f5a 100644 --- a/src/collective/cover/tests/test_tiles.py +++ b/src/collective/cover/tests/test_tiles.py @@ -30,6 +30,5 @@ def test_tiles_removed_on_uninstall(self): self.assertTrue(u'collective.cover.collection' not in tiles) self.assertTrue(u'collective.cover.embed' not in tiles) self.assertTrue(u'collective.cover.file' not in tiles) - self.assertTrue(u'collective.cover.link' not in tiles) self.assertTrue(u'collective.cover.list' not in tiles) self.assertTrue(u'collective.cover.richtext' not in tiles) diff --git a/src/collective/cover/tiles/image.py b/src/collective/cover/tiles/image.py deleted file mode 100644 index 74e7ca18e..000000000 --- a/src/collective/cover/tiles/image.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- coding: utf-8 -*- -from collective.cover import _ -from collective.cover.tiles.base import IPersistentCoverTile -from collective.cover.tiles.base import PersistentCoverTile -from plone.memoize.instance import memoizedproperty -from plone.namedfile.field import NamedBlobImage as NamedImage -from plone.tiles.interfaces import ITileDataManager -from plone.uuid.interfaces import IUUID -from Products.CMFCore.utils import getToolByName -from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile -from zope import schema -from zope.deprecation import deprecated -from zope.interface import implements - - -class IImageTile(IPersistentCoverTile): - - image = NamedImage( - title=_(u'Image'), - required=False, - ) - - uuid = schema.TextLine( - title=_(u'UUID'), - required=False, - readonly=True, - ) - - -class ImageTile(PersistentCoverTile): - - implements(IImageTile) - - index = ViewPageTemplateFile('templates/image.pt') - - is_configurable = True - - @memoizedproperty - def brain(self): - catalog = getToolByName(self.context, 'portal_catalog') - uuid = self.data.get('uuid') - result = catalog(UID=uuid) if uuid is not None else [] - assert len(result) <= 1 - return result[0] if result else None - - def Date(self): - """ Return the date of publication of the original object; if it has - not been published yet, it will return its modification date. - """ - if self.brain is not None: - return self.brain.Date - - def is_empty(self): - return self.brain is None and \ - not [i for i in self.data.values() if i] - - def getURL(self): - """ Return the URL of the original object. - """ - if self.brain is not None: - return self.brain.getURL() - - def description(self): - """ Return the description of the original image - """ - if self.brain is not None: - return self.brain.Description - - def title(self): - """ Return the title of the original image - """ - if self.brain is not None: - return self.brain.Title - - def populate_with_object(self, obj): - # check permissions - super(ImageTile, self).populate_with_object(obj) - - data = { - 'uuid': IUUID(obj, None), # XXX: can we get None here? see below - } - - # TODO: if a Dexterity object does not have the IReferenceable - # behaviour enable then it will not work here - # we need to figure out how to enforce the use of - # plone.app.referenceablebehavior - data_mgr = ITileDataManager(self) - data_mgr.set(data) - - def accepted_ct(self): - return ['Image'] - - -deprecated( - 'IImageTile', - "Image Tile is deprecated use Banner Tile instead. Image Tile will be " - "removed in collective.cover 1.0a5.") diff --git a/src/collective/cover/tiles/link.py b/src/collective/cover/tiles/link.py deleted file mode 100644 index f1a65bbc2..000000000 --- a/src/collective/cover/tiles/link.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- - -from collective.cover import _ -from collective.cover.tiles.base import IPersistentCoverTile -from collective.cover.tiles.base import PersistentCoverTile -from plone.namedfile.field import NamedBlobImage as NamedImage -from plone.tiles.interfaces import ITileDataManager -from plone.uuid.interfaces import IUUID -from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile -from zope import schema -from zope.deprecation import deprecated -from zope.interface import implements - - -class ILinkTile(IPersistentCoverTile): - - title = schema.TextLine( - title=_(u'Title'), - required=False, - ) - - description = schema.Text( - title=_(u'Description'), - required=False, - ) - - image = NamedImage( - title=_(u'Image'), - required=False, - ) - - remote_url = schema.TextLine( - title=_(u'URL'), - required=False, - ) - - uuid = schema.TextLine( - title=_(u'UUID'), - required=False, - readonly=True, # the field can not be edited or configured - ) - - -class LinkTile(PersistentCoverTile): - - implements(ILinkTile) - - index = ViewPageTemplateFile('templates/link.pt') - - # TODO: make it configurable - is_configurable = False - - # XXX: can we do this without waking the object up? - # XXX: commented because we're not rendering the date -# def get_date(self): -# # TODO: we must support be able to select which date we want to -# # display -# obj = uuidToObject(self.data['uuid']) -# if obj: -# return obj.Date() - - def get_remote_url(self): - return self.data['remote_url'] - - def is_empty(self): - return not(self.data.get('title') or - self.data.get('description') or - self.data.get('image') or - self.data.get('remote_url') or - self.data.get('uuid')) - - def populate_with_object(self, obj): - super(LinkTile, self).populate_with_object(obj) # check permissions - - title = obj.Title() - description = obj.Description() - remote_url = obj.getRemoteUrl() - uuid = IUUID(obj, None) - - data_mgr = ITileDataManager(self) - data_mgr.set({'title': title, - 'description': description, - 'remote_url': remote_url, - 'uuid': uuid, - }) - - def accepted_ct(self): - """ Return a list of content types accepted by the tile. - """ - return ['Link'] - - -deprecated( - 'LinkTile', - "Link Tile is deprecated use Banner Tile instead. Link Tile will be " - "removed in collective.cover 1.0a5.") diff --git a/src/collective/cover/tiles/templates/image.pt b/src/collective/cover/tiles/templates/image.pt deleted file mode 100644 index c2907c157..000000000 --- a/src/collective/cover/tiles/templates/image.pt +++ /dev/null @@ -1,38 +0,0 @@ - - - -

- Drag&drop an image here to populate the tile. -

- -
- - - - - - - - - - -
-
-
-
- - diff --git a/src/collective/cover/tiles/templates/link.pt b/src/collective/cover/tiles/templates/link.pt deleted file mode 100644 index f7a3e2601..000000000 --- a/src/collective/cover/tiles/templates/link.pt +++ /dev/null @@ -1,50 +0,0 @@ - - - -

- Please drag&drop a link here to populate the tile. -

- - - - diff --git a/src/collective/cover/tiles/tiles.zcml b/src/collective/cover/tiles/tiles.zcml index 41ca250d9..28cc4e99e 100644 --- a/src/collective/cover/tiles/tiles.zcml +++ b/src/collective/cover/tiles/tiles.zcml @@ -101,30 +101,6 @@ for="*" /> - - - -