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 option to show/hide thumbs in site-controlpanel #73

Merged
merged 1 commit into from
Nov 16, 2015
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
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