Ignore:
Timestamp:
8 May 2012, 19:14:36 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganise links in manage bar. Ensure that all link texts are translated.

We do no longer need the LeftSidebarLink? base class.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/browser.py

    r8194 r8387  
    256256    """Link in upper left box to access code management.
    257257    """
    258     grok.order(6)
     258    grok.order(4)
    259259    grok.require('waeup.manageACBatches')
    260260
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/staffsitelayout.pt

    r8278 r8387  
    8282            <h5 tal:content="layout/getUserTitle">USERNAME</h5>
    8383            <ul>
    84               <tal:left content="structure provider:left" />
     84              <tal:left content="structure provider:left_manage" />
    8585            </ul>
    8686          </div>
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r8374 r8387  
    4141grok.context(IKofaObject) # Make IKofaObject the default context
    4242
    43 class LeftSidebar(grok.ViewletManager):
    44     grok.name('left')
     43class ManageSidebar(grok.ViewletManager):
     44    grok.name('left_manage')
    4545
    4646class BreadCrumbManager(grok.ViewletManager):
     
    248248#        self.can_import = not ISite.providedBy(self.context)
    249249
    250 class LeftSidebarLink(grok.Viewlet):
    251     """ An entry on left sidebar.
    252 
    253     This is only a baseclass that won't be rendered actually. Deriving
    254     viewlets can override certain values and will be rendered with the
    255     values set here as default.
    256     """
    257     grok.baseclass()
    258     grok.viewletmanager(LeftSidebar)
    259     grok.context(IKofaObject)
    260     grok.order(5)
    261     grok.require('waeup.manageAcademics')
    262     icon = 'actionicon_modify.png' # File must exist in static/
    263     title = 'Text of link'
    264 
    265     @property
    266     def url(self):
    267         return '@@index'
    268 
    269     @property
    270     def icon_url(self):
    271         """Get the icon URL.
    272         """
    273         if self.icon:
    274             static = self.view.static
    275             if static is None or static.get(self.icon, None) is None:
    276                 # In derived classes defined in other modules/packages
    277                 # than w.k.browser, ``static`` might refer to a static dir
    278                 # local to the derived class' module. As we often like to
    279                 # get the icons from here
    280                 # (i.e. waeup.kofa.browser/static), we set the directory
    281                 # resource appropiately.
    282                 #
    283                 # XXX: The hardcoding of 'w.k.browser' should be replaced
    284                 #      by something smarter.
    285                 #
    286                 # TODO: notes in here should go to general documentation.
    287                 static = queryAdapter(
    288                     self.request, Interface, name='waeup.kofa.browser')
    289             return static[self.icon]()
    290         return
    291    
    292     # Render link only if url is provided.
    293     def render(self):
    294         if self.url:
    295             if self.icon_url:
    296                 return u'<li><a href="%s"><img src="%s" /> %s </a></li>' % (
    297                     self.url, self.icon_url, self.title)
    298             else:
    299                 return u'<li><a href="%s">%s </a></li>' % (
    300                     self.url, self.title)
    301         else:
    302             return ''
    303250
    304251class WidgetsTableRows(grok.Viewlet):
     
    309256
    310257
    311 #
    312 # waeup.kofa.app.University viewlets...
    313 #
    314258class Login(grok.Viewlet):
    315259    """This viewlet allows to login in the sidebar.
    316260    """
    317     grok.viewletmanager(LeftSidebar)
     261    grok.viewletmanager(ManageSidebar)
    318262    grok.context(IKofaObject)
    319263    grok.view(Interface)
     
    346290    every page the user is allowed to go to, if the user has also the
    347291    permissions set by `grok.require()`. By default only users with
    348     ``waeup.manageAcademics`` permission will see links defined by
     292    ``waeup.managePortal`` permission will see links defined by
    349293    this or derivated classes.
    350294    """
    351     grok.viewletmanager(LeftSidebar)
     295    grok.baseclass()
     296    grok.viewletmanager(ManageSidebar)
    352297    grok.context(IKofaObject)
    353298    grok.view(Interface)
    354     grok.order(5)
     299    grok.order(1)
    355300    # This link is only displayed, if the user is
    356301    # allowed to use it!
    357     grok.require('waeup.managePortalConfiguration')
    358 
    359     link = 'configuration'
    360     text = _(u'Portal Configuration')
     302    grok.require('waeup.managePortal')
     303
     304    link = 'relative_link'
     305    text = _(u'Any link text')
    361306   
    362307    def render(self):
     
    366311                url, text)
    367312
     313class ManagePortalConfiguration(ManageLink):
     314    """A link to portal configuration.
     315    """
     316    grok.order(2)
     317    grok.require('waeup.managePortalConfiguration')
     318
     319    link = 'configuration'
     320    text = _(u'Portal Configuration')
     321
    368322class ManageUsersLink(ManageLink):
    369323    """A link to users management, placed in upper left box.
    370324    """
    371     grok.order(6)
     325    grok.order(2)
    372326    grok.require('waeup.manageUsers')
    373327
    374328    link = u'users'
    375329    text = _(u'Portal Users')
     330
     331class ManageDataCenter(ManageLink):
     332    """A link to datacenter, placed in upper left box.
     333    """
     334    grok.order(3)
     335    grok.require('waeup.manageDataCenter')
     336
     337    link = u'datacenter'
     338    text = _(u'Data Center')
     339
     340class MyPreferences(ManageLink):
     341    """A link to personal preferences, placed in upper left box.
     342    """
     343    grok.order(6)
     344    grok.require('waeup.Public')
     345    text = _(u'My Preferences')
     346
     347    def render(self):
     348        account_object = get_user_account(self.request)
     349        if account_object:
     350            url = self.view.url(account_object)
     351            text = translate(self.text, context=self.request)
     352            return u'<li><a href="%s">%s</a></li>' % (
     353                    url, text)
     354        return ''
     355
     356class MyRoles(ManageLink):
     357    """A link to display site and local roles.
     358    """
     359    grok.order(7)
     360    grok.require('waeup.Public')
     361    text = _(u'My Roles')
     362
     363    def render(self):
     364        account_object = get_user_account(self.request)
     365        if account_object:
     366            url = self.view.url(account_object) + '/my_roles'
     367            text = translate(self.text, context=self.request)
     368            return u'<li><a href="%s">%s</a></li>' % (
     369                    url, text)
     370        return ''
    376371
    377372class ContactActionButton(ManageActionButton):
     
    383378    text = _('Send email')
    384379    target = 'contactuser'
    385 
    386 class ManageDataCenter(ManageLink):
    387     """A link to datacenter, placed in upper left box.
    388     """
    389     grok.order(6)
    390     grok.require('waeup.manageDataCenter')
    391 
    392     link = u'datacenter'
    393     text = _(u'Data Center')
    394 
    395 class MyPreferences(LeftSidebarLink):
    396     """A link to personal preferences, placed in upper left box.
    397     """
    398     grok.order(7)
    399     grok.require('waeup.Public')
    400     title = _(u'My Preferences')
    401     icon = ''
    402 
    403     @property
    404     def url(self):
    405         account_object = get_user_account(self.request)
    406         if account_object:
    407             return self.view.url(account_object)
    408         return
    409 
    410 class MyRoles(LeftSidebarLink):
    411     """A link to display site and local roles.
    412     """
    413     grok.order(8)
    414     grok.require('waeup.Public')
    415     title = _(u'My Roles')
    416     icon = ''
    417 
    418     @property
    419     def url(self):
    420         account_object = get_user_account(self.request)
    421         if account_object:
    422             return self.view.url(account_object) + '/my_roles'
    423         return
    424 
    425 #
    426 # Manage ("Edit settings") actions...
    427 #
    428380
    429381class ManageDataCenterActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.