Changeset 6687 for main/waeup.sirp/trunk


Ignore:
Timestamp:
6 Sep 2011, 08:22:00 (13 years ago)
Author:
Henrik Bettermann
Message:

Tweak site layout for students (experimental!). Students should see only a one-column.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
4 edited

Legend:

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

    r6642 r6687  
    1111from zope.interface import Interface
    1212from zope.site.hooks import getSite
    13 from waeup.sirp.interfaces import IWAeUPObject
     13from waeup.sirp.interfaces import IWAeUPObject, IUserAccount
    1414from waeup.sirp.browser.interfaces import ITheme
    1515from waeup.sirp.browser.theming import get_all_themes, WAeUPThemeGray1
    1616from waeup.sirp.students.interfaces import IStudentNavigation
     17from waeup.sirp.authentication import get_principal_role_manager
    1718
    1819grok.templatedir('templates')
     
    160161        return
    161162
     163    def isStudent(self):
     164        prm = get_principal_role_manager()
     165        roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]
     166        return 'waeup.Student' in roles
     167
     168    def tableClass(self):
     169        if self.isStudent():
     170            return 'yui-t7'
     171        return 'yui-t1'
     172
    162173    def update(self):
    163174        """Include the resources required by the chosen skin/theme.
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/sitelayout.pt

    r6653 r6687  
    1515  </head>
    1616  <body class="rounded yui-skin-sam">
    17     <div id="doc3" class="yui-t1">
     17    <div id="doc3" tal:attributes= "class layout/tableClass">
    1818      <div id="hd" role="banner">
    1919        <div id="hd">
     
    2525            </span> </h1>
    2626          <div id="navigation" class="yui-navset" style="text-align:right;">
    27             <ul id="primary-navigation">
     27            <ul id="primary-navigation" tal:condition="not: layout/isStudent">
    2828              <tal:primary_nav content="structure provider:primary_nav" />
     29            </ul>
     30            <ul id="primary-navigation" tal:condition="layout/isStudent">
     31              <tal:primary_nav content="structure provider:primary_nav_student" />
    2932            </ul>
    3033            <ul id="user-navigation" tal:condition="layout/isAuthenticated">
     
    4447      </div>
    4548      <div id="bd" role="main">
    46         <span tal:condition="layout/isAuthenticated"
     49        <span tal:condition="python: layout.isAuthenticated() and not layout.isStudent()"
    4750              tal:content="structure provider:breadcrumbs" />
     51
     52        <div class="yui-b" tal:condition="not: layout/isStudent">
     53          <div class="block" tal:condition="layout/getStudentName">
     54            <div class="hd">
     55              <h2 tal:content="layout/getStudentName">Student name</h2>
     56            </div>
     57            <div class="bd">
     58              <tal:left content="structure provider:left_studentmanage" />
     59            </div>
     60          </div>
     61          <div class="block">
     62            <div class="hd">
     63              <h2 tal:content="layout/getUserTitle">Username</h2>
     64            </div>
     65            <div class="bd">
     66              <tal:left content="structure provider:left" />
     67            </div>
     68          </div>
     69        </div>
     70
     71        <div class="yui-b" tal:condition="layout/isStudent">
     72          <div class="block" tal:condition="layout/getStudentName">
     73            <div>
     74              <tal:left content="structure provider:top_student" />
     75            </div>
     76          </div>
     77        </div>
     78
    4879        <div id="yui-main">
    4980          <div class="yui-b">
    5081            <div class="yui-g">
    5182              <div class="block">
    52                 <div class="hd">
     83                <div class="hd" tal:condition="not: layout/isStudent">
    5384                  <span tal:content="view/title"> THE CONTENT TITLE </span>
    5485                  <span tal:condition="layout/getStudentName" class="wfstatus">
     
    77108          </div>
    78109        </div>
    79         <div class="yui-b">
    80           <div class="block" tal:condition="layout/getStudentName">
    81             <div class="hd">
    82               <h2 tal:content="layout/getStudentName">Student name</h2>
    83             </div>
    84             <div class="bd">
    85               <tal:left content="structure provider:left_student" />
    86             </div>
    87           </div>
    88           <div class="block">
    89             <div class="hd">
    90               <h2 tal:content="layout/getUserTitle">Username</h2>
    91             </div>
    92             <div class="bd">
    93               <tal:left content="structure provider:left" />
    94             </div>
    95           </div>
    96         </div>
     110
    97111      </div>
    98112      <div id="ft" role="contentinfo">
  • main/waeup.sirp/trunk/src/waeup/sirp/students/permissions.py

    r6683 r6687  
    3939class StudentRole(grok.Role):
    4040    grok.name('waeup.Student')
    41     grok.permissions('waeup.Public')
     41    grok.permissions('waeup.Public', 'waeup.View')
    4242
    4343class StudentsOfficer(grok.Role):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r6660 r6687  
    44
    55grok.context(IWAeUPObject) # Make IWAeUPObject the default context
     6grok.templatedir('browser_templates')
    67
    7 class StudentSidebar(grok.ViewletManager):
    8     grok.name('left_student')
     8class StudentManageSidebar(grok.ViewletManager):
     9    grok.name('left_studentmanage')
    910
    10 class StudentLink(grok.Viewlet):
     11class StudentManageLink(grok.Viewlet):
    1112    """A link displayed in the student box which shows up for StudentNavigation
    1213    objects.
     
    1415    """
    1516    grok.baseclass()
    16     grok.viewletmanager(StudentSidebar)
     17    grok.viewletmanager(StudentManageSidebar)
    1718    grok.context(IWAeUPObject)
    1819    grok.view(Interface)
     
    2728        return u'<div class="portlet"><a href="%s">%s</a></div>' % (
    2829                url, self.text)
     30
     31class StudentManageBaseLink(StudentManageLink):
     32    grok.order(1)
     33    link = 'index'
     34    text = u'Base Data'
     35
     36class StudentManageClearanceLink(StudentManageLink):
     37    grok.order(2)
     38    link = 'view_clearance'
     39    text = u'Clearance Data'
     40
     41class StudentManagePersonalLink(StudentManageLink):
     42    grok.order(2)
     43    link = 'view_personal'
     44    text = u'Personal Data'
     45
     46class StudentManageStudyCourseLink(StudentManageLink):
     47    grok.order(3)
     48    link = 'studycourse'
     49    text = u'Study Course'
     50
     51class StudentManagePaymentsLink(StudentManageLink):
     52    grok.order(4)
     53    link = 'payments'
     54    text = u'Payments'
     55
     56class StudentManageAccommodationLink(StudentManageLink):
     57    grok.order(5)
     58    link = 'accommodation'
     59    text = u'Accommodation Data'
     60
     61class StudentManageHistoryLink(StudentManageLink):
     62    grok.order(6)
     63    link = 'history'
     64    text = u'History'
     65
     66
     67class StudentMenu(grok.ViewletManager):
     68    grok.name('top_student')
     69
     70class StudentLink(grok.Viewlet):
     71    """A link displayed in the student box which shows up for StudentNavigation
     72    objects.
     73
     74    """
     75    grok.baseclass()
     76    grok.viewletmanager(StudentMenu)
     77    grok.context(IWAeUPObject)
     78    grok.view(Interface)
     79    grok.order(5)
     80    grok.require('waeup.viewStudent')
     81    template = grok.PageTemplateFile('browser_templates/plainactionbutton.pt')
     82
     83    link = 'index'
     84    text = u'Base Data'
     85
     86    @property
     87    def alt(self):
     88        """Alternative text for icon.
     89        """
     90        return self.text
     91
     92    @property
     93    def target_url(self):
     94        """Get a URL to the target...
     95        """
     96        return self.view.url(self.context.getStudent(), self.link)
    2997
    3098class StudentBaseLink(StudentLink):
     
    56124    grok.order(5)
    57125    link = 'accommodation'
    58     text = u'Accommodation Data'
     126    text = u'Accommodation'
    59127
    60128class StudentHistoryLink(StudentLink):
     
    62130    link = 'history'
    63131    text = u'History'
     132
     133class PrimaryStudentNavManager(grok.ViewletManager):
     134    """Viewlet manager for the primary navigation tab.
     135    """
     136    grok.name('primary_nav_student')
     137
     138class PrimaryStudentNavTab(grok.Viewlet):
     139    """Base for primary student nav tabs.
     140    """
     141    grok.baseclass()
     142    grok.viewletmanager(PrimaryStudentNavManager)
     143    grok.template('primarynavtab')
     144    grok.order(1)
     145    grok.require('waeup.View')
     146    pnav = 0
     147    tab_title = u'Some Text'
     148
     149    @property
     150    def link_target(self):
     151        return self.view.application_url()
     152
     153    @property
     154    def active(self):
     155        view_pnav = getattr(self.view, 'pnav', 0)
     156        if view_pnav == self.pnav:
     157            return 'active'
     158        return ''
     159
     160class HomeTab(PrimaryStudentNavTab):
     161    """Home-tab in primary navigation.
     162    """
     163    grok.order(1)
     164    grok.require('waeup.Public')
     165    pnav = 0
     166    tab_title = u'Home'
     167
     168class ProspectusTab(PrimaryStudentNavTab):
     169    """Faculties-tab in primary navigation.
     170    """
     171    grok.order(2)
     172    grok.require('waeup.View')
     173    pnav = 1
     174    tab_title = u'Prospectus'
     175
     176    @property
     177    def link_target(self):
     178        return self.view.application_url('faculties')
     179
     180class MyDataTab(PrimaryStudentNavTab):
     181    """MyData-tab in primary navigation.
     182    """
     183    grok.order(3)
     184    grok.require('waeup.Public')
     185    pnav = 4
     186    tab_title = u'My Data'
     187
     188    @property
     189    def link_target(self):
     190        rel_link = '/students/%s' % self.request.principal.id
     191        return self.view.application_url() + rel_link
Note: See TracChangeset for help on using the changeset viewer.