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

Fix show_more_link and more_link_text default values #3

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.1.2 (unreleased)
------------------

- Nothing changed yet.
- Fix default values for ``show_more_link`` and ``more_link_text``
[petschki]


1.1.1 (2024-06-06)
Expand Down
3 changes: 1 addition & 2 deletions src/collective/gridlisting/behaviors/grid_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from plone import api
from plone import schema
from plone.autoform.interfaces import IFormFieldProvider
from plone.base.utils import safe_hasattr
from plone.supermodel import directives
from plone.supermodel import model
from Products.CMFPlone.utils import safe_hasattr
from z3c.form.interfaces import IValue
from zope.component import adapter
from zope.interface import implementer
Expand Down Expand Up @@ -104,7 +104,6 @@ class IGridListing(model.Schema):
),
required=False,
default=False,
missing_value=False,
)

more_link_text = schema.TextLine(
Expand Down
5 changes: 2 additions & 3 deletions src/collective/gridlisting/browser/grid_listing.pt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
thumb_scale_summary python:view.w['IGridListing.preview_scale'].value or 'preview';
enable_masonry python:'selected' in view.w['IGridListing.enable_masonry'].value;
masonry_options python:view.w['IGridListing.masonry_options'].value;
show_more_link_val python:view.w['IGridListing.show_more_link'].value or [];
show_more_link python:'selected' in show_more_link_val;
more_link_text python:view.w['IGridListing.more_link_text'].value or 'more';
show_more_link python:view.get_default('show_more_link');
more_link_text python:view.get_default('more_link_text');
"
>
<div class="row ${row_css_class} ${python:'pat-masonry' if enable_masonry else ''}"
Expand Down
26 changes: 24 additions & 2 deletions src/collective/gridlisting/browser/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
from Acquisition import aq_inner
from plone import api
from plone.app.contenttypes.browser.collection import CollectionView
from plone.app.contenttypes.browser.folder import FolderView
from plone.dexterity.browser.view import DefaultView


class FolderGridListing(FolderView, DefaultView):
class GridListingBase(DefaultView):

def get_default(self, attr):
context = aq_inner(self.context)
val = getattr(context, attr, None)
if val is None:
if attr in self.w:
# return widgets default attribute adapter
return self.w[attr].value
return
return val

@property
def show_about(self):
# use registry setting even if not anonymous
return api.portal.get_registry_record(
"plone.allow_anon_views_about", default=False
)


class FolderGridListing(GridListingBase, FolderView):
pass


class CollectionGridListing(CollectionView, DefaultView):
class CollectionGridListing(GridListingBase, CollectionView):
pass