Skip to content
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

Merged
merged 4 commits into from
Aug 30, 2018
Merged

Add group carousel tile #235

merged 4 commits into from
Aug 30, 2018

Conversation

claytonc
Copy link
Contributor

No description provided.

CHANGES.rst Outdated
@@ -4,6 +4,9 @@ Changelog
2.0a1 (unreleased)
^^^^^^^^^^^^^^^^^^

- Adiciona um tile para mostrar um Carroussel de grupo.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carrossel

Copy link
Contributor Author

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):
Copy link
Member

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.

Copy link
Contributor Author

@claytonc claytonc Aug 29, 2018

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)])
Copy link
Member

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?

Copy link
Contributor Author

@claytonc claytonc Aug 29, 2018

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.

[1] https://github.com/collective/collective.cover/blob/master/src/collective/cover/tiles/list.py#L162-L169

:param obj: [required] The object to be added
:type obj: Content object
"""
super(GroupCarouselTile, self).populate_with_object(obj) # check permission
Copy link
Member

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().

Copy link
Contributor Author

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()):
Copy link
Member

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.

Copy link
Contributor Author

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() == []
Copy link
Member

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.

Copy link
Contributor Author

@claytonc claytonc Aug 29, 2018

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

Copy link
Member

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()).

Copy link
Contributor Author

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;
Copy link
Member

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?

Copy link
Member

@rodfersou rodfersou left a 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

@hvelarde hvelarde merged commit b4d57ef into master Aug 30, 2018
@hvelarde hvelarde deleted the add-groupcarousel branch August 30, 2018 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants