Changeset 7336 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 13 Dec 2011, 07:30:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/dynamicroles.py
r7334 r7336 46 46 rolename_mapping = { 47 47 'waeup.local.ClearanceOfficer':'waeup.StudentsClearanceOfficer', 48 'waeup.local.CourseAdviser100':'waeup.StudentsCourseAdviser',49 'waeup.local.CourseAdviser200':'waeup.StudentsCourseAdviser',50 'waeup.local.CourseAdviser300':'waeup.StudentsCourseAdviser',51 'waeup.local.CourseAdviser400':'waeup.StudentsCourseAdviser',52 'waeup.local.CourseAdviser500':'waeup.StudentsCourseAdviser',53 'waeup.local.CourseAdviser600':'waeup.StudentsCourseAdviser'54 48 } 55 49 … … 101 95 self._context[self.subcontainer], self.extra_attrib, None) 102 96 current_level = getattr( 103 self._context[self.subcontainer], 'current_level', None)97 self._context[self.subcontainer], 'current_level', 0) 104 98 else: 105 99 obj = getattr(self._context, self.extra_attrib, None) 106 current_level = None107 # lookup local roles for connected course and all parent100 current_level = 0 101 # Lookup local roles for connected course and all parent 108 102 # objects. This way we fake 'role inheritance'. 109 103 while obj is not None: … … 111 105 principal_id) 112 106 for role_id, setting in extra_roles: 113 if role_id in self.rolename_mapping.keys(): 114 # Found role in external attribute or parent 115 # thereof. 'Grant' additional role 116 # permissions (allow, deny or unset) for the 117 # passed in principal id. 118 # Make an exception for Course Advisers: 119 # Grant additional role only if external role corresponds 120 # with current_level of student. 121 if not current_level or \ 122 'CourseAdviser' not in role_id or \ 123 str(current_level) in role_id: 107 if 'CourseAdviser' in role_id: 108 # Found a Course Adviser role in external attribute or parent 109 # thereof. We need a special treatment for Course Advisers. 110 if str(100*(current_level/100)) in role_id: 111 # Grant additional role, which allows to validate or reject 112 # course lists, only if external role corresponds 113 # with current_level of student. 124 114 result.append( 125 (self.rolename_mapping[role_id], setting)) 115 ('waeup.StudentsCourseAdviser', setting)) 116 else: 117 # Otherwise grant at least view permissions. 118 result.append( 119 ('waeup.StudentsOfficer', setting)) 120 elif role_id in self.rolename_mapping.keys(): 121 # Grant additional role 122 # permissions (allow, deny or unset) 123 # according to the rolename mapping above. 124 result.append( 125 (self.rolename_mapping[role_id], setting)) 126 126 return result 127 127 obj = getattr(obj, '__parent__', None)
Note: See TracChangeset for help on using the changeset viewer.