Ignore:
Timestamp:
24 May 2013, 17:54:10 (11 years ago)
Author:
Henrik Bettermann
Message:

Add local and global ApplicationsManager? role. Assign role dynamically.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/dynamicroles.py

    r8964 r10226  
    4242    # role to add in case this role was found
    4343    rolename_mapping = {
    44         'waeup.local.ClearanceOfficer':'waeup.ApplicationsOfficer',
     44        'waeup.local.ApplicationsManager':'waeup.ApplicationsManager',
    4545        }
    4646
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/permissions.py

    r8565 r10226  
    6060class ApplicationsOfficer(grok.Role):
    6161    grok.name('waeup.ApplicationsOfficer')
    62     grok.title(u'Applications Officer')
     62    grok.title(u'Applications Officer (view only)')
     63    grok.permissions('waeup.viewApplication', 'waeup.viewApplicantsTab')
     64
     65class ApplicationsManager(grok.Role):
     66    grok.name('waeup.ApplicationsManager')
     67    grok.title(u'Applications Manager')
    6368    grok.permissions('waeup.manageApplication', 'waeup.viewApplication',
    6469                     'waeup.viewApplicantsTab', 'waeup.payApplicant')
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r10210 r10226  
    297297        return
    298298
    299     # We have no local roles yet
    300     #def test_local_roles_add_delete(self):
    301     #    # Managers can assign and delete local roles of applicants root
    302     #    myusers = self.app['users']
    303     #    myusers.addUser('bob', 'bobssecret')
    304     #    self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    305     #    self.browser.open(self.manage_root_path)
    306     #    self.browser.getControl(name="user").value = ['bob']
    307     #    self.browser.getControl(name="local_role").value = [
    308     #        'waeup.local.ApplicationsOfficer']
    309     #    self.browser.getControl("Add local role").click()
    310     #    self.assertTrue('<td>bob</td>' in self.browser.contents)
    311     #    # Remove the role assigned
    312     #    ctrl = self.browser.getControl(name='role_id')
    313     #    ctrl.getControl(value='bob|waeup.ApplicationsOfficer').selected = True
    314     #    self.browser.getControl("Remove selected local roles").click()
    315     #    self.assertTrue('Successfully removed:' in self.browser.contents)
    316     #    self.assertFalse('<td>bob</td>' in self.browser.contents)
    317     #    return
     299    def test_local_roles_add_delete(self):
     300        # Managers can assign and delete local roles of applicants root
     301        myusers = self.app['users']
     302        myusers.addUser('bob', 'bobssecret')
     303        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     304        self.browser.open('http://localhost/app/faculties/fac1/dep1/manage')
     305        self.browser.getControl(name="user").value = ['bob']
     306        self.browser.getControl(name="local_role").value = [
     307            'waeup.local.ApplicationsManager']
     308        self.browser.getControl("Add local role").click()
     309        self.assertTrue('<td>bob</td>' in self.browser.contents)
     310        # Remove the role assigned
     311        ctrl = self.browser.getControl(name='role_id')
     312        ctrl.getControl(
     313            value='bob|waeup.local.ApplicationsManager').selected = True
     314        self.browser.getControl("Remove selected local roles").click()
     315        self.assertTrue(
     316            'Local role successfully removed: bob|waeup.local.ApplicationsManager'
     317            in self.browser.contents)
     318        self.assertFalse('<td>bob</td>' in self.browser.contents)
     319        return
    318320
    319321    def test_add_delete_container(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_dynamicroles.py

    r7811 r10226  
    4747        super(ApplicantPrincipalRoleManagerFunctionalTests, self).setUp()
    4848        self.applicant.course1 = self.certificate
    49         self.officer_role = 'waeup.ApplicationsOfficer'
    50         # assign clearance permissions for a virtual officer
     49        # assign application manage permissions for a virtual officer
    5150        prm = IPrincipalRoleManager(self.department)
    52         prm.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'alice')
     51        prm.assignRoleToPrincipal('waeup.local.ApplicationsManager', 'alice')
    5352        return
    5453
     
    7877
    7978    def test_valid_officer(self):
    80         # for an officer that has clearance role on the connected dept
    81         # we get the ApplicationsOfficer role on our applicant
     79        # for an officer that has application manage permissions
     80        # on the connected dept
     81        # we get the ApplicationsManager role on our applicant
    8282        prm = IPrincipalRoleManager(self.applicant)
    8383        result = prm.getRolesForPrincipal('alice')
    84         self.assertEqual(result, [('waeup.ApplicationsOfficer', Allow)])
     84        self.assertEqual(result, [('waeup.ApplicationsManager', Allow)])
    8585        return
Note: See TracChangeset for help on using the changeset viewer.