Ignore:
Timestamp:
24 Nov 2011, 09:20:13 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganise permissions:

The navigation viewlets now manage the permission requirements themselves. No need to do this in pagetemplates.

Rename permission waeup.View to waeup.viewAcademics because it only refers to the academic section.

Add permission waeup.Authenticated (which is used in students). The StudentRecordOwner? explicitly needs this permission. Otherwise the MyData? tab disappears when changing the password.

Roles do not need to get the waeup.Public permission. This is already guaranteed in site.zcml.

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

Legend:

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

    r7166 r7184  
    234234        return self.context.access_code
    235235
    236 class ApplicantsTab(PrimaryNavTab):
     236class ApplicantsAuthTab(PrimaryNavTab):
    237237    """Applicants tab in primary navigation.
    238238    """
    239 
    240239    grok.context(IWAeUPObject)
    241240    grok.order(3)
    242     grok.require('waeup.Public')
     241    grok.require('waeup.viewApplication')
    243242    grok.template('primarynavtab')
    244 
    245243    pnav = 3
    246244    tab_title = u'Applicants'
     
    249247    def link_target(self):
    250248        return self.view.application_url('applicants')
     249
     250class ApplicantsAnonTab(ApplicantsAuthTab):
     251    """Applicants tab in primary navigation.
     252
     253    Display tab only for anonymous. Authenticated users can call the
     254    form from the user navigation bar.
     255    """
     256    grok.require('waeup.Anonymous')
     257    tab_title = u'Application'
     258
     259    # Also zope.manager has role Anonymous.
     260    # To avoid displaying this tab, uncomment the following.
     261    #def tab_title(self):
     262    #    userid = self.request.principal.id
     263    #    if userid != 'zope.anybody':
     264    #        tt = u''
     265    #    else:
     266    #        tt = u'Application'
     267    #    return tt
    251268
    252269class ApplicantsContainerPage(WAeUPDisplayFormPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/permissions.py

    r7178 r7184  
    4646class ApplicantRole(grok.Role):
    4747    grok.name('waeup.Applicant')
    48     grok.permissions('waeup.Public', 'waeup.View')
     48    grok.permissions('waeup.viewAcademics')
    4949
    5050class ApplicationsOfficer(grok.Role):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py

    r7137 r7184  
    138138            'Manage' in self.browser.contents)
    139139
     140   
    140141    def test_anonymous_no_actions(self):
    141142        # Make sure anonymous users cannot access actions
     
    173174        return
    174175
    175     def test_local_roles_add_delete(self):
    176         # Managers can assign and delete local roles of applicants root
    177         myusers = self.app['users']
    178         myusers.addUser('bob', 'bobssecret')
    179         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    180         self.browser.open(self.manage_root_path)
    181         self.browser.getControl(name="user").value = ['bob']
    182         self.browser.getControl(name="local_role").value = [
    183             'waeup.ApplicationsOfficer']
    184         self.browser.getControl("Add local role").click()
    185         self.assertTrue('<td>bob</td>' in self.browser.contents)
    186         # Remove the role assigned
    187         ctrl = self.browser.getControl(name='role_id')
    188         ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
    189         self.browser.getControl("Remove selected local roles").click()
    190         self.assertTrue('Successfully removed:' in self.browser.contents)
    191         self.assertFalse('<td>bob</td>' in self.browser.contents)
    192         return
     176    # We have no local roles yet
     177    #def test_local_roles_add_delete(self):
     178    #    # Managers can assign and delete local roles of applicants root
     179    #    myusers = self.app['users']
     180    #    myusers.addUser('bob', 'bobssecret')
     181    #    self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     182    #    self.browser.open(self.manage_root_path)
     183    #    self.browser.getControl(name="user").value = ['bob']
     184    #    self.browser.getControl(name="local_role").value = [
     185    #        'waeup.local.ApplicationsOfficer']
     186    #    self.browser.getControl("Add local role").click()
     187    #    self.assertTrue('<td>bob</td>' in self.browser.contents)
     188    #    # Remove the role assigned
     189    #    ctrl = self.browser.getControl(name='role_id')
     190    #    ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
     191    #    self.browser.getControl("Remove selected local roles").click()
     192    #    self.assertTrue('Successfully removed:' in self.browser.contents)
     193    #    self.assertFalse('<td>bob</td>' in self.browser.contents)
     194    #    return
    193195
    194196    def test_add_delete_container(self):
     
    423425        return
    424426
    425     def test_local_roles_add_delete(self):
    426         # Managers can assign and delete local roles of applicants containers
    427         myusers = self.app['users']
    428         myusers.addUser('bob', 'bobssecret')
    429         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    430         self.browser.open(self.manage_container_path)
    431         self.browser.getControl(name="user").value = ['bob']
    432         self.browser.getControl(name="local_role").value = [
    433             'waeup.ApplicationsOfficer']
    434         self.browser.getControl("Add local role").click()
    435         self.assertTrue('<td>bob</td>' in self.browser.contents)
    436         ctrl = self.browser.getControl(name='role_id')
    437         ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
    438         self.browser.getControl("Remove selected local roles").click()
    439         self.assertTrue('Successfully removed:' in self.browser.contents)
    440         self.assertFalse('<td>bob</td>' in self.browser.contents)
    441         return
     427    # We have no local roles yet
     428    #def test_local_roles_add_delete(self):
     429    #    # Managers can assign and delete local roles of applicants containers
     430    #    myusers = self.app['users']
     431    #    myusers.addUser('bob', 'bobssecret')
     432    #    self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     433    #    self.browser.open(self.manage_container_path)
     434    #    self.browser.getControl(name="user").value = ['bob']
     435    #    self.browser.getControl(name="local_role").value = [
     436    #        'waeup.local.ApplicationsOfficer']
     437    #    self.browser.getControl("Add local role").click()
     438    #    self.assertTrue('<td>bob</td>' in self.browser.contents)
     439    #    ctrl = self.browser.getControl(name='role_id')
     440    #    ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
     441    #    self.browser.getControl("Remove selected local roles").click()
     442    #    self.assertTrue('Successfully removed:' in self.browser.contents)
     443    #    self.assertFalse('<td>bob</td>' in self.browser.contents)
     444    #    return
    442445
    443446class LoginTest(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.