Skip to content

Commit

Permalink
Merge pull request #258 from plone/thet-1734-cleanup
Browse files Browse the repository at this point in the history
Cleanup of PLIP #1734
  • Loading branch information
thet authored Jun 14, 2017
2 parents 58ddf17 + 957e91a commit ae81d0f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions plone/app/event/portlets/portlet_events.pt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</a>
</header>
<section class="portletContent">
<ul tal:define="thumb_size view/thumb_size">
<ul tal:define="thumb_scale view/thumb_scale">
<tal:events repeat="item view/events">
<li class="portletItem"
tal:define="oddrow repeat/item/odd;
Expand All @@ -30,7 +30,7 @@
title item_descr"
tal:define="scale item/context/@@images|nothing;">
<span tal:condition="item_hasimage">
<img tal:define="img_tag python:scale.scale('image', scale=thumb_size).tag(css_class='pull-right image-'+thumb_size)"
<img tal:define="img_tag python:scale.scale('image', scale=thumb_scale).tag(css_class='pull-right image-'+thumb_scale)"
tal:replace="structure img_tag" />
</span>
<span tal:replace="item_title">Some Event</span>
Expand Down
56 changes: 32 additions & 24 deletions plone/app/event/portlets/portlet_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,40 @@ class IEventsPortlet(IPortletDataProvider):
required=False,
source=search_base_uid_source,
)
ov_thumbsize = schema.TextLine(
title=_(u"Override thumb size "),
description=_(u"<br><ul><li> Enter a valid scale name"
u"(see 'Image Handling' control panel) to override"
u" e.g. icon, tile, thumb, mini, preview, ... ) </li>"
u"<li>leave empty to use default "
u"(see 'Site' control panel)</li></ul>"),
thumb_scale = schema.TextLine(
title=_(u"Override thumb scale"),
description=_(
u"Enter a valid scale name"
u" (see 'Image Handling' control panel) to override"
u" (e.g. icon, tile, thumb, mini, preview, ... )."
u" Leave empty to use default (see 'Site' control panel)."
),
required=False,
default=u'')

no_thumbs = schema.Bool(
title=_(u"Suppress thumbs "),
title=_(u"Suppress thumbs"),
description=_(
u"If enabled, the portlet will not show thumbs"),
u"If enabled, the portlet will not show thumbs."),
required=True,
default=False)


@implementer(IEventsPortlet)
class Assignment(base.Assignment):

# reduce upgrade pain
search_base = None
thumb_scale = None
no_thumbs = False

def __init__(self, count=5, state=None, search_base_uid=None):
def __init__(self, count=5, state=None, search_base_uid=None,
thumb_scale=None, no_thumbs=False):
self.count = count
self.state = state
self.search_base_uid = search_base_uid
self.thumb_scale = thumb_scale
self.no_thumbs = no_thumbs

@property
def title(self):
Expand Down Expand Up @@ -209,25 +216,26 @@ def formatted_date(self, event):
IContentProvider, name='formatted_date'
)
return provider(event)
def thumb_size(self):
''' use overrride value or read thumb_size from registry
image sizes must fit to value in allowed image sizes
none will suppress thumb!
'''
if getattr(self.data,'no_thumbs',False):
#individual setting overrides ...
return 'none'
thsize=getattr(self.data,'ov_thumbsize','')
if thsize > ' ':

def thumb_scale(self):
"""Use override value or read thumb_scale from registry.
Image sizes must fit to value in allowed image sizes.
None will suppress thumb.
"""
if getattr(self.data, 'no_thumbs', False):
# Individual setting overrides ...
return None
thsize = getattr(self.data, 'thumb_scale', None)
if thsize:
return thsize
registry = getUtility(IRegistry)
settings = registry.forInterface(
ISiteSchema, prefix="plone", check=False)
if settings.no_thumbs_portlet:
return 'none'
thumb_size_portlet = settings.thumb_size_portlet
return thumb_size_portlet
return None
thumb_scale_portlet = settings.thumb_scale_portlet
return thumb_scale_portlet


class AddForm(base.AddForm):
schema = IEventsPortlet
Expand Down

0 comments on commit ae81d0f

Please sign in to comment.