Changeset 7243


Ignore:
Timestamp:
1 Dec 2011, 10:11:59 (13 years ago)
Author:
Henrik Bettermann
Message:

Use only one primarynavtab.pt pagetemplate and render list item only if link_target is provided.

Provide link_target of EnquiriesTab? and ApplicantsAnonTab? only if principal id is zope.anybody.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
3 deleted
6 edited

Legend:

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

    r7240 r7243  
    234234    grok.order(3)
    235235    grok.require('waeup.viewApplicationsTab')
    236     grok.template('primarynavtab')
    237236    pnav = 3
    238237    tab_title = u'Applicants'
     
    252251
    253252    # Also zope.manager has role Anonymous.
    254     # To avoid displaying this tab, uncomment the following.
    255     #def tab_title(self):
    256     #    userid = self.request.principal.id
    257     #    if userid != 'zope.anybody':
    258     #        tt = u''
    259     #    else:
    260     #        tt = u'Application'
    261     #    return tt
     253    # To avoid displaying this tab, we have to check the principal id too.
     254    @property
     255    def link_target(self):
     256        if self.request.principal.id == 'zope.anybody':
     257            return self.view.application_url('applicants')
     258        return
    262259
    263260class MyApplicationDataTab(PrimaryStudentNavTab):
     
    266263    grok.order(3)
    267264    grok.require('waeup.viewMyApplicationDataTab')
    268     grok.template('primarynavtab')
    269265    pnav = 3
    270266    tab_title = u'My Data'
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py

    r7240 r7243  
    4444default_waeup_edit_template.__grok_name__ = 'default_waeup_edit_form'
    4545
     46default_primary_nav_template = grokcore.view.PageTemplateFile(
     47    os.path.join('templates', 'primarynavtab.pt'))
     48default_primary_nav_template.__grok_name__ = 'default_primary_nav'
     49
    4650
    4751def NullValidator(*args, **kw):
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/primarynavtab.pt

    r4789 r7243  
    1 <li tal:attributes="class viewlet/active">
     1<li tal:attributes="class viewlet/active" tal:condition="viewlet/link_target">
    22  <a href="#"
    33     tal:attributes="href viewlet/link_target"
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r7231 r7243  
    3030from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPXMLExporter,
    3131                                   IWAeUPXMLImporter, IDataCenter, IUserAccount)
    32 from waeup.sirp.browser.layout import WAeUPPage
     32from waeup.sirp.browser.layout import WAeUPPage, default_primary_nav_template
    3333from waeup.sirp.utils.helpers import get_user_account
    3434
     
    571571    grok.order(1)
    572572    grok.require('waeup.Public')
     573    template = default_primary_nav_template
    573574
    574575    pnav = 0 # This is a kind of id of a tab. If some page provides
     
    600601    grok.order(1)
    601602    grok.require('waeup.Public')
    602     grok.template('primarynavtab')
    603603
    604604    pnav = 0
     
    610610    grok.order(2)
    611611    grok.require('waeup.viewAcademics')
    612     grok.template('primarynavtab')
    613612
    614613    pnav = 1
     
    628627    grok.order(6)
    629628    grok.require('waeup.Anonymous')
    630     grok.template('primarynavtab')
    631629    tab_title = u'Enquiries'
    632630    pnav = 2
    633631
     632    # Also zope.manager has role Anonymous.
     633    # To avoid displaying this tab, we have to check the principal id too.
    634634    @property
    635635    def link_target(self):
    636         return self.view.application_url('enquiries')
     636        if self.request.principal.id == 'zope.anybody':
     637            return self.view.application_url('enquiries')
     638        return
    637639
    638640#
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/browser.py

    r7195 r7243  
    2828from waeup.sirp.browser.breadcrumbs import Breadcrumb
    2929from waeup.sirp.browser.resources import datepicker, datatable, tabs, toggleall
     30from waeup.sirp.browser.layout import default_primary_nav_template
     31from waeup.sirp.browser.pages import delSubobjects
    3032from waeup.sirp.browser.viewlets import (
    3133    ManageActionButton, PrimaryNavTab, AddActionButton)
     
    3436    FriendlyDateWidget, FriendlyDateDisplayWidget,
    3537    FriendlyDatetimeDisplayWidget)
    36 from waeup.sirp.browser.pages import delSubobjects
    3738from waeup.sirp.authentication import get_principal_role_manager
    3839from waeup.sirp.hostels.container import HostelsContainer
     
    6869    grok.order(5)
    6970    grok.require('waeup.viewHostels')
    70     grok.template('primarynavtab')
    71 
     71    template = default_primary_nav_template
    7272    pnav = 5
    7373    tab_title = u'Hostels'
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r7240 r7243  
    2525from waeup.sirp.browser import DEFAULT_IMAGE_PATH
    2626from waeup.sirp.browser.viewlets import PrimaryNavTab
     27from waeup.sirp.browser.layout import default_primary_nav_template
    2728from waeup.sirp.students.browser import (
    2829    StudentClearanceDisplayFormPage, StudentClearanceManageFormPage,
     
    164165    grok.order(4)
    165166    grok.require('waeup.viewStudentsTab')
    166     grok.template('primarynavtab')
    167167
    168168    pnav = 4
     
    183183    grok.baseclass()
    184184    grok.viewletmanager(PrimaryStudentNavManager)
    185     grok.template('primarynavtab')
     185    template = default_primary_nav_template
    186186    grok.order(1)
    187187    grok.require('waeup.Authenticated')
Note: See TracChangeset for help on using the changeset viewer.