Changeset 7220


Ignore:
Timestamp:
26 Nov 2011, 22:19:41 (13 years ago)
Author:
Henrik Bettermann
Message:

Use rolename_mapping dictionary instead of external_rolenames and additional_rolename.

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

Legend:

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

    r7192 r7220  
    4343    subcontainer = None
    4444
    45     #: List of role names to look for in `extra_attrib` and parents.
    46     external_rolenames = ['waeup.local.ClearanceOfficer',]
    47 
    48     #: Role to add in case one of the above roles was found.
    49     additional_rolename = 'waeup.ApplicationsOfficer'
     45    # Role name mapping:
     46    # role name to look for in `extra_attrib` and parents
     47    # to
     48    # role to add in case this role was found
     49    rolename_mapping = {
     50        'waeup.local.ClearanceOfficer':'waeup.ApplicationsOfficer',
     51        }
  • main/waeup.sirp/trunk/src/waeup/sirp/students/dynamicroles.py

    r7159 r7220  
    4242    subcontainer = 'studycourse'
    4343
    44     #: List of role names to look for in `extra_attrib` and parents.
    45     external_rolenames = ['waeup.local.ClearanceOfficer',]
    46 
    47     #: Role to add in case one of the above roles was found.
    48     additional_rolename = 'waeup.StudentsClearanceOfficer'
     44    # Role name mapping:
     45    # role name to look for in `extra_attrib` and parents
     46    # to
     47    # role to add in case this role was found
     48    rolename_mapping = {
     49        'waeup.local.ClearanceOfficer':'waeup.StudentsClearanceOfficer',
     50        'waeup.local.CourseAdviser100':'waeup.StudentsCourseAdviser100',
     51        'waeup.local.CourseAdviser200':'waeup.StudentsCourseAdviser200',
     52        'waeup.local.CourseAdviser300':'waeup.StudentsCourseAdviser300',
     53        'waeup.local.CourseAdviser400':'waeup.StudentsCourseAdviser400',
     54        'waeup.local.CourseAdviser500':'waeup.StudentsCourseAdviser500',
     55        'waeup.local.CourseAdviser600':'waeup.StudentsCourseAdviser600'
     56        }
    4957
    5058    def getRolesForPrincipal(self, principal_id):
     
    102110                principal_id)
    103111            for role_id, setting in extra_roles:
    104                 if role_id in self.external_rolenames:
     112                if role_id in self.rolename_mapping.keys():
    105113                    # Found role in external attribute or parent
    106114                    # thereof. 'Grant' additional role
     
    108116                    # passed in principal id.
    109117                    result.append(
    110                         (self.additional_rolename, setting))
     118                        (self.rolename_mapping[role_id], setting))
    111119                    return result
    112120            obj = getattr(obj, '__parent__', None)
Note: See TracChangeset for help on using the changeset viewer.