Changeset 8387 for main/waeup.kofa/trunk/src/waeup/kofa/browser
- Timestamp:
- 8 May 2012, 19:14:36 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/staffsitelayout.pt
r8278 r8387 82 82 <h5 tal:content="layout/getUserTitle">USERNAME</h5> 83 83 <ul> 84 <tal:left content="structure provider:left " />84 <tal:left content="structure provider:left_manage" /> 85 85 </ul> 86 86 </div> -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r8374 r8387 41 41 grok.context(IKofaObject) # Make IKofaObject the default context 42 42 43 class LeftSidebar(grok.ViewletManager):44 grok.name('left ')43 class ManageSidebar(grok.ViewletManager): 44 grok.name('left_manage') 45 45 46 46 class BreadCrumbManager(grok.ViewletManager): … … 248 248 # self.can_import = not ISite.providedBy(self.context) 249 249 250 class LeftSidebarLink(grok.Viewlet):251 """ An entry on left sidebar.252 253 This is only a baseclass that won't be rendered actually. Deriving254 viewlets can override certain values and will be rendered with the255 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 @property266 def url(self):267 return '@@index'268 269 @property270 def icon_url(self):271 """Get the icon URL.272 """273 if self.icon:274 static = self.view.static275 if static is None or static.get(self.icon, None) is None:276 # In derived classes defined in other modules/packages277 # than w.k.browser, ``static`` might refer to a static dir278 # local to the derived class' module. As we often like to279 # get the icons from here280 # (i.e. waeup.kofa.browser/static), we set the directory281 # resource appropiately.282 #283 # XXX: The hardcoding of 'w.k.browser' should be replaced284 # 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 return291 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 ''303 250 304 251 class WidgetsTableRows(grok.Viewlet): … … 309 256 310 257 311 #312 # waeup.kofa.app.University viewlets...313 #314 258 class Login(grok.Viewlet): 315 259 """This viewlet allows to login in the sidebar. 316 260 """ 317 grok.viewletmanager( LeftSidebar)261 grok.viewletmanager(ManageSidebar) 318 262 grok.context(IKofaObject) 319 263 grok.view(Interface) … … 346 290 every page the user is allowed to go to, if the user has also the 347 291 permissions set by `grok.require()`. By default only users with 348 ``waeup.manage Academics`` permission will see links defined by292 ``waeup.managePortal`` permission will see links defined by 349 293 this or derivated classes. 350 294 """ 351 grok.viewletmanager(LeftSidebar) 295 grok.baseclass() 296 grok.viewletmanager(ManageSidebar) 352 297 grok.context(IKofaObject) 353 298 grok.view(Interface) 354 grok.order( 5)299 grok.order(1) 355 300 # This link is only displayed, if the user is 356 301 # allowed to use it! 357 grok.require('waeup.managePortal Configuration')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') 361 306 362 307 def render(self): … … 366 311 url, text) 367 312 313 class 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 368 322 class ManageUsersLink(ManageLink): 369 323 """A link to users management, placed in upper left box. 370 324 """ 371 grok.order( 6)325 grok.order(2) 372 326 grok.require('waeup.manageUsers') 373 327 374 328 link = u'users' 375 329 text = _(u'Portal Users') 330 331 class 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 340 class 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 356 class 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 '' 376 371 377 372 class ContactActionButton(ManageActionButton): … … 383 378 text = _('Send email') 384 379 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 @property404 def url(self):405 account_object = get_user_account(self.request)406 if account_object:407 return self.view.url(account_object)408 return409 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 @property419 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 return424 425 #426 # Manage ("Edit settings") actions...427 #428 380 429 381 class ManageDataCenterActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.