Changeset 7167


Ignore:
Timestamp:
22 Nov 2011, 14:09:55 (13 years ago)
Author:
Henrik Bettermann
Message:

Add MyPreferences? viewlet to the LeftSidebar?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r7137 r7167  
    33import grok
    44
    5 from zope.component import getMultiAdapter, queryAdapter
     5from zope.component import getMultiAdapter, queryAdapter, getUtility
    66from zope.interface import Interface
    77from zope.location.interfaces import ISite
     8from zope.traversing.browser import absoluteURL
     9from zope.pluggableauth.interfaces import IAuthenticatorPlugin
    810from waeup.sirp.browser.pages import (
    911    UniversityPage, FacultyContainerPage, DatacenterPage, FacultyPage,
     
    329331    text = u'Data Center'
    330332
     333class MyPreferences(LeftSidebarLink):
     334    """A link to personal preferences, placed in upper left box.
     335    """
     336    grok.order(7)
     337    grok.require('waeup.Public')
     338    title = u'My Preferences'
     339    icon = ''
     340
     341    def getUserAccount(self):
     342        """Return local user account.
     343        """
     344        principal_id = self.request.principal.id
     345        authenticator = getUtility(IAuthenticatorPlugin, name='users')
     346        account = authenticator.getAccount(principal_id)
     347        return account
     348
     349    @property
     350    def url(self):
     351        account_object = self.getUserAccount()
     352        if account_object:
     353            return absoluteURL(account_object, self.request)
     354        return
     355
    331356#
    332357# Manage ("Edit settings") actions...
    333358#
    334 #class ManageUniversityActionButton(ManageActionButton):
    335 #    """ 'Edit' button for University instances.
    336 #    """
    337 #    grok.context(IUniversity)
    338 #    grok.view(UniversityPage)
    339 #    text = 'Edit portal settings'
    340    
    341 #class ManageFacultiesActionButton(ManageActionButton):
    342 #    """ 'Edit settings' button for faculty container.
    343 #    """
    344 #    grok.context(IFacultyContainer)
    345 #    grok.view(FacultyContainerPage)
    346359
    347360class ManageDataCenterActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.