-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add group carousel tile #235
Conversation
CHANGES.rst
Outdated
@@ -4,6 +4,9 @@ Changelog | |||
2.0a1 (unreleased) | |||
^^^^^^^^^^^^^^^^^^ | |||
|
|||
- Adiciona um tile para mostrar um Carroussel de grupo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Carrossel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
from zope.interface import implementer | ||
|
||
|
||
class IGroupCarouselTile(IListTile): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're inheriting here from IListTile
but below we inherit from CarouselTile
; why we're doing this? that's confusing and error prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
:type obj: Content object | ||
""" | ||
super(GroupCarouselTile, self).populate_with_object(obj) # check permission | ||
self.populate_with_uuids([self.get_uuid(obj)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this skips all the logic for populating the tile with a collection, is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method to maintain the same functionality of ListTile
[1], because CarouselTile
only accepts content with images.
This tile works with collections.
:param obj: [required] The object to be added | ||
:type obj: Content object | ||
""" | ||
super(GroupCarouselTile, self).populate_with_object(obj) # check permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is already done in populate_with_uuids()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
"""Return the list of objects stored in the tile.""" | ||
page = [] | ||
|
||
for i, item in enumerate(super(GroupCarouselTile, self).results()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use enumerate(self.results(), start=1)
instead to avoid having to add 1 to i on the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
altered to enumerate(super(GroupCarouselTile, self).results(), start=1)
enumerate(self.results(), start=1)
=> RuntimeError: maximum recursion depth exceeded while calling a Python object
|
||
def is_empty(self): | ||
"""Check if the tile is empty.""" | ||
return super(GroupCarouselTile, self).results() == [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no need to use super()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 -
def is_empty(self):
"""Check if the tile is empty."""
return super(GroupCarouselTile, self).results() == []
Or
2 -
def is_empty(self):
"""Check if the tile is empty."""
try:
next(self.results())
except StopIteration:
return True
return False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh, sorry; I see self.results()
is now an iterator.
it's up to you, an alternate solution could be return list(self.results())
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not work return list(self.results())
, I searched a lot about it.
<tal:image define="thumbnail python:view.thumbnail(obj);" | ||
condition="thumbnail"> | ||
<a tal:attributes="href python:view.get_url(obj)"> | ||
<img tal:attributes="src thumbnail/url|string:${item/absolute_url}/download; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a workaround for collective/collective.cover#801?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update documentation with the use case of two of this tile inserted in the same row/column and rethink the name of the parameter used to describe the tab name
739cae8
to
1adde62
Compare
No description provided.