Skip to content

Commit

Permalink
Add option to show/hide thumbs in site-controlpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrcon committed Nov 15, 2015
1 parent 6a2cb28 commit 9957887
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Changelog

New:

- *add item here*
- Add option to show/hide thumbs in site-controlpanel
https://github.com/plone/Products.CMFPlone/issues/1241
[fgrcon]

Fixes:

Expand Down
24 changes: 24 additions & 0 deletions plone/app/layout/globals/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ def icons_visible(self):
else:
return False

@memoize
def thumb_visible(self):
"""Returns True if thumbs should be shown or False otherwise.
"""
context = self.context
membership = getToolByName(context, "portal_membership")
anon = membership.isAnonymousUser()
registry = getUtility(IRegistry)
settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
thumb_visibility = settings.thumb_visibility

if thumb_visibility == 'enabled':
return True
elif thumb_visibility == 'authenticated' and not anon:
return True
else:
return False

def getIcon(self, item):
"""Returns an object which implements the IContentIcon interface and
provides the informations necessary to render an icon. The item
Expand Down Expand Up @@ -179,6 +197,12 @@ def bodyClass(self, template, view):
else:
body_classes.append('icons-off')

# class for hiding thumbs (optional)
if self.thumb_visible():
body_classes.append('thumbs-on')
else:
body_classes.append('thumbs-off')

# permissions required. Useful to theme frontend and backend
# differently
permissions = []
Expand Down

0 comments on commit 9957887

Please sign in to comment.