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

Redirect students to their data page after login.

Fix test.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/browser
Files:
2 edited

Legend:

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

    r6612 r6686  
    4040from waeup.sirp.users import LocalRoleSetEvent
    4141from waeup.sirp.widgets.restwidget import ReSTDisplayWidget
     42from waeup.sirp.authentication import get_principal_role_manager
    4243
    4344
     
    102103    camefrom = None
    103104
     105    def isStudent(self):
     106        prm = get_principal_role_manager()
     107        roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]
     108        return 'waeup.Student' in roles
     109
    104110    def update(self, SUBMIT=None, camefrom=None):
    105111        self.camefrom = camefrom
     
    107113            if self.request.principal.id != 'zope.anybody':
    108114                self.flash('You logged in.')
     115                if self.isStudent():
     116                    rel_link = '/students/%s' % self.request.principal.id
     117                    self.redirect(self.application_url() + rel_link)
     118                    return
    109119                if not self.camefrom:
    110120                    # User might have entered the URL directly. Let's beam
     
    116126            self.flash('You entered wrong credentials.')
    117127
    118 class LoginStaffPage(LoginPage):
    119     """A login page for staff members.
    120     """
    121     grok.name('loginstaff')
    122     grok.template('loginstaffpage')
    123     grok.require('waeup.Public')
    124     title = u'Staff Login'
    125 
    126 class LoginStudentPage(LoginPage):
    127     """A login page for students.
    128     """
    129     grok.name('loginstudent')
    130     grok.template('loginstudentpage')
    131     grok.require('waeup.Public')
    132     title = u'Student Login'
    133128
    134129class LogoutPage(WAeUPPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/tests/test_permissions.py

    r6658 r6686  
    6464public_pages = [
    6565    # Pages accessible also by the public...
    66     '/@@index', '/@@login','/@@loginstaff', '/@@loginstudent', '/@@logout',
     66    '/@@index', '/@@login', '/@@logout',
    6767    ]
    6868
Note: See TracChangeset for help on using the changeset viewer.