- Timestamp:
- 19 Mar 2007, 21:45:44 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/branches/joachim-event-branch/PatchCPSUserFolderUserFolder.py
r1558 r1596 71 71 ## patch to assign dynamic roles for WAeUP 72 72 while 1: 73 if self.isStudent(): 74 break 75 groups = self.portal_membership.getAuthenticatedMember().getGroups() 76 if not ("ClearanceOfficers" in groups or "CourseAdvisers" in groups): 77 break 73 78 if callable(real_object) and hasattr(real_object,'im_self'): 74 79 real_object = real_object.im_self 75 80 81 if real_object is None: 82 break 76 83 if hasattr(real_object,'portal_type') and\ 77 real_object.portal_type not in ("Student","StudentClearance","StudentStudyLevel"): 84 real_object.portal_type not in ("Student", 85 "StudentClearance", 86 "StudentStudyLevel"): 78 87 break 79 80 #from pdb import set_trace;set_trace() 88 # don't test if it is not a proxy 89 if real_object.portal_type == real_object.meta_type: 90 break 81 91 # can be later simplified by replacing by students_catalog values - Henrik 82 92 # getattr works always because of acquisition ?! Henrik … … 84 94 if sc is None: 85 95 break 96 #from pdb import set_trace;set_trace() 86 97 sc_obj = sc.getContent() 87 98 cert_id = sc_obj.study_course … … 110 121 ) 111 122 if real_object.portal_type == "StudentStudyLevel": 112 context_obj = getattr(certificate_obj,real_object.getId()) 113 allowed = ('CourseAdviser', 'SectionManager') 123 context_obj = getattr(certificate_obj,real_object.getId(),None) 124 if context_obj is None: 125 break 126 allowed = set(('CourseAdviser', 'SectionManager')) 127 elif real_object.portal_type == "Student" and "CourseAdvisers" in groups: 128 #we need some special processing since CourseAdvisers are only 129 #specified per StudyLevel 130 allowed = set(('CourseAdviser', 'SectionManager')) 131 for context_obj in certificate_obj.objectValues(): 132 dynamic_roles = set(self.getRolesInContext(context_obj)) 133 intersect = dynamic_roles & allowed 134 if intersect: 135 roles.extend(list(intersect)) 136 break 114 137 else: 115 138 res = self.portal_catalog(portal_type="Department",id=dep_id) 116 allowed = ('ClearanceOfficer', 'SectionManager')139 allowed = set(('ClearanceOfficer', 'SectionManager')) 117 140 if len(res) != 1: 118 141 break 119 142 context_obj = res[0].getObject() 120 dynamic_roles = se lf.getRolesInContext(context_obj)121 for dr in allowed:122 if dr in dynamic_roles:123 roles.append(dr)143 dynamic_roles = set(self.getRolesInContext(context_obj)) 144 intersect = dynamic_roles & allowed 145 if intersect: 146 roles.extend(list(intersect)) 124 147 break 125 148 return roles
Note: See TracChangeset for help on using the changeset viewer.