Changeset 10226


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

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

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
9 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
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/browser.txt

    r10207 r10226  
    217217  >>> print browser.contents
    218218  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    219   ...<td nowrap>Applications Officer <br /></td>
     219  ...<td nowrap>Applications Officer (view only) <br /></td>
    220220  ...
    221221
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.py

    r10177 r10226  
    7878
    7979# Local Roles
     80class ApplicationsManager(grok.Role):
     81    grok.name('waeup.local.ApplicationsManager')
     82    grok.title(u'Applications Manager')
     83    grok.permissions('waeup.viewAcademics')
     84
    8085class DepartmentManager(grok.Role):
    8186    grok.name('waeup.local.DepartmentManager')
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt

    r10177 r10226  
    3939    >>> from waeup.kofa.permissions import get_waeup_roles
    4040    >>> len(list(get_waeup_roles()))
    41     20
     41    21
    4242
    4343    >>> len(list(get_waeup_roles(also_local=True)))
    44     36
     44    38
    4545
    4646
     
    5858     u'waeup.AccommodationOfficer',
    5959     u'waeup.Applicant',
     60     u'waeup.ApplicationsManager',
    6061     u'waeup.ApplicationsOfficer',
    6162     u'waeup.CCOfficer',
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_dynamicroles.py

    r8963 r10226  
    8282    def test_valid_officer(self):
    8383        # for an officer that has clearance role on the connected dept
    84         # we get the ApplicationsOfficer role on our student
     84        # we get the ClearanceOfficer role on our student
    8585        prm = IPrincipalRoleManager(self.student)
    8686        result = prm.getRolesForPrincipal('alice')
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r10064 r10226  
    3939
    4040    local_roles = [
     41        'waeup.local.ApplicationsManager',
    4142        'waeup.local.DepartmentManager',
    4243        'waeup.local.ClearanceOfficer',
Note: See TracChangeset for help on using the changeset viewer.