-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
372 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
exclude_paths: | ||
- bootstrap.py | ||
- setup.py | ||
- webpack/vendor/swiper.min.js | ||
- webpack/vendor/swiper.min.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# -*- coding: utf-8 -*- | ||
from brasil.gov.tiles.testing import BaseIntegrationTestCase | ||
from brasil.gov.tiles.tiles.photogallery import PhotoGalleryTile | ||
from collective.cover.tiles.base import IPersistentCoverTile | ||
from mock import Mock | ||
from plone.tiles.interfaces import ITileDataManager | ||
from zope.interface.verify import verifyClass | ||
from zope.interface.verify import verifyObject | ||
|
||
|
||
class PhotoGalleryTileTestCase(BaseIntegrationTestCase): | ||
|
||
def setUp(self): | ||
super(PhotoGalleryTileTestCase, self).setUp() | ||
self.tile = self.portal.restrictedTraverse( | ||
'@@{0}/{1}'.format('brasil.gov.tiles.photogallery', 'test-tile')) | ||
|
||
def test_interface(self): | ||
self.assertTrue(IPersistentCoverTile.implementedBy(PhotoGalleryTile)) | ||
self.assertTrue(verifyClass(IPersistentCoverTile, PhotoGalleryTile)) | ||
|
||
tile = PhotoGalleryTile(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.assertListEqual(self.tile.accepted_ct(), ['Image']) | ||
|
||
def test_tile_is_empty(self): | ||
self.assertTrue(self.tile.is_empty()) | ||
|
||
def test_render_empty(self): | ||
msg = 'Drag&drop an image here to populate the tile.' | ||
|
||
self.tile.is_compose_mode = Mock(return_value=True) | ||
self.assertIn(msg, self.tile()) | ||
|
||
self.tile.is_compose_mode = Mock(return_value=False) | ||
self.assertNotIn(msg, self.tile()) | ||
|
||
def test_crud(self): | ||
self.assertTrue(self.tile.is_empty()) | ||
|
||
obj = self.portal['my-image'] | ||
obj2 = self.portal['my-image1'] | ||
obj3 = self.portal['my-image2'] | ||
|
||
self.tile.populate_with_object(obj) | ||
self.tile.populate_with_object(obj2) | ||
self.tile.populate_with_object(obj3) | ||
|
||
self.tile = self.portal.restrictedTraverse( | ||
'@@{0}/{1}'.format('brasil.gov.tiles.photogallery', 'test-tile')) | ||
|
||
self.assertEqual(len(self.tile.results()), 3) | ||
self.assertIn(obj, self.tile.results()) | ||
self.assertIn(obj2, self.tile.results()) | ||
self.assertIn(obj3, self.tile.results()) | ||
|
||
data = self.tile.data | ||
data['tile_title'] = 'My title' | ||
data_mgr = ITileDataManager(self.tile) | ||
data_mgr.set(data) | ||
|
||
self.tile = self.portal.restrictedTraverse( | ||
'@@{0}/{1}'.format('brasil.gov.tiles.photogallery', 'test-tile')) | ||
self.assertEqual(self.tile.tile_title, 'My title') | ||
|
||
def test_render_with_image(self): | ||
obj = self.portal['my-image'] | ||
self.tile.populate_with_object(obj) | ||
rendered = self.tile() | ||
self.assertFalse(self.tile.is_empty()) | ||
self.assertIn('<img ', rendered) | ||
self.assertIn('alt="This image was created for testing purposes"', rendered) | ||
|
||
def test_thumbnail(self): | ||
obj = self.portal['my-image'] | ||
thumbnail = self.tile.thumbnail(obj) | ||
self.assertIsNotNone(thumbnail) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
from brasil.gov.tiles import _ | ||
from collective.cover.interfaces import ITileEditForm | ||
from collective.cover.tiles.list import IListTile | ||
from collective.cover.tiles.list import ListTile | ||
from collective.cover.widgets.textlinessortable import TextLinesSortableFieldWidget | ||
from plone.autoform import directives as form | ||
from plone.tiles.interfaces import ITileDataManager | ||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile | ||
from zope import schema | ||
from zope.interface import implementer | ||
|
||
|
||
class IPhotoGalleryTile(IListTile): | ||
"""A tile that shows an photo gallery.""" | ||
|
||
tile_description = schema.Text(title=_(u'Tile Description'), required=False) | ||
form.omitted('tile_description') | ||
form.no_omit(ITileEditForm, 'tile_description') | ||
|
||
form.no_omit(ITileEditForm, 'uuids') | ||
form.widget(uuids=TextLinesSortableFieldWidget) | ||
|
||
|
||
@implementer(IPhotoGalleryTile) | ||
class PhotoGalleryTile(ListTile): | ||
"""A tile that shows an photo gallery.""" | ||
|
||
index = ViewPageTemplateFile('templates/photogallery.pt') | ||
short_name = _(u'msg_short_photo_gallery', default=u'Photo Gallery') | ||
is_configurable = True | ||
is_droppable = True | ||
is_editable = True | ||
limit = 5 * 3 | ||
|
||
@staticmethod | ||
def accepted_ct(): | ||
return ['Image'] | ||
|
||
def get_description(self, item): | ||
"""Get the description of the item, or the custom description | ||
if set. | ||
:param item: [required] The item for which we want the description | ||
:type item: Content object | ||
:returns: the item description | ||
:rtype: unicode | ||
""" | ||
# First we get the url for the item itself | ||
description = item.Description() | ||
uuid = self.get_uuid(item) | ||
data_mgr = ITileDataManager(self) | ||
data = data_mgr.get() | ||
uuids = data['uuids'] | ||
if uuid in uuids: | ||
if uuids[uuid].get('custom_description', u''): | ||
# If we had a custom description set, then get that | ||
description = uuids[uuid].get('custom_description') | ||
return description | ||
|
||
@staticmethod | ||
def get_credits(item): | ||
return item.Rights() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:metal="http://xml.zope.org/namespaces/metal" | ||
xmlns:tal="http://xml.zope.org/namespaces/tal" | ||
xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
i18n:domain="brasil.gov.tiles"> | ||
<body tal:define="is_empty view/is_empty"> | ||
|
||
<p tal:condition="python: is_empty and view.is_compose_mode()" i18n:translate=""> | ||
Drag&drop an image here to populate the tile. | ||
</p> | ||
|
||
<div class="brasil-photogallery-tile tile-content" | ||
tal:attributes="id string:gallery-${view/id}" | ||
tal:condition="not:is_empty"> | ||
<h3 class="gallery-title" tal:content="view/tile_title" /> | ||
<div class="swiper-container photogallery-container"> | ||
<div class="swiper-wrapper"> | ||
<tal:items repeat="item view/results"> | ||
<div class="swiper-slide" | ||
tal:attributes="data-tile-id view/id; | ||
data-content-type item/portal_type; | ||
data-content-uuid python:view.get_uuid(item)"> | ||
<div class="image-container"> | ||
<tal:image tal:define="thumbnail python:view.thumbnail(item);" | ||
tal:condition="thumbnail"> | ||
<img tal:attributes="src thumbnail/url; | ||
class string:gallery-image; | ||
alt python:view.get_alt(item);" /> | ||
<div class="container-bar"> | ||
<div class="text-bottom"> | ||
<p class="description" tal:content="python:view.get_description(item)">Description</p> | ||
<p class="credits" tal:content="python:view.get_credits(item)">Credits</p> | ||
</div> | ||
|
||
<div class="links-bottom"> | ||
<a tal:attributes="href string:${item/absolute_url}/@@download/image" class="download-icon">Download</a> | ||
<a tal:attributes="href string:${item/absolute_url}/@@images/image" class="zoom-icon">Zoom</a> | ||
</div> | ||
</div> | ||
</tal:image> | ||
</div> | ||
</div> | ||
</tal:items> | ||
</div> | ||
<div class="swiper-button-next swiper-button-white"></div> | ||
<div class="swiper-button-prev swiper-button-white"></div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.