Back to index

plone3  3.1.7
dashboard.py
Go to the documentation of this file.
00001 from zope.component import getUtility
00002 
00003 from Products.Five.browser import BrowserView
00004 
00005 from plone.portlets.interfaces import IPortletManager
00006 from plone.portlets.constants import USER_CATEGORY
00007 
00008 from plone.memoize.instance import memoize
00009 
00010 from Products.CMFCore.utils import getToolByName
00011 
00012 class DashboardView(BrowserView):
00013     """Power the dasbhard
00014     """
00015     
00016     @memoize
00017     def empty(self):
00018         dashboards = [getUtility(IPortletManager, name=name) for name in
00019                         ['plone.dashboard1', 'plone.dashboard2', 'plone.dashboard3', 'plone.dashboard4']]
00020                         
00021         portal_membership = getToolByName(self.context, 'portal_membership')
00022         userid = portal_membership.getAuthenticatedMember().getId()
00023                         
00024         num_portlets = 0
00025         for dashboard in dashboards:
00026             num_portlets += len(dashboard.get(USER_CATEGORY, {}).get(userid, {}))
00027         return num_portlets == 0