Changeset 2055
- Timestamp:
- 25 Jul 2007, 14:56:32 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/PatchCPSUserFolderUserFolder.py
r1959 r2055 6 6 security = ClassSecurityInfo() 7 7 8 def getCertificateObject(self,st_entry): 9 try: 10 return getattr(getattr(getattr(self.portal_url.getPortalObject().campus.academics, 11 st_entry.faculty), 12 st_entry_department).certificate, 13 st_entry.course) 14 except: 15 return None 16 8 17 security.declarePublic('getRolesInContext') 9 18 def getRolesInContext(self, object): … … 95 104 real_object.portal_type not in ("Student", 96 105 "StudentClearance", 97 "StudentStudyLevel"): 106 "StudentStudyLevel", 107 "StudentCourseResult", 108 ): 98 109 break 99 110 … … 104 115 # can be later simplified by replacing by students_catalog values - Henrik 105 116 # getattr works always because of acquisition ?! Henrik 106 sc = getattr(real_object,'study_course',None)107 if sc is None:108 break109 sc_obj = sc.getContent()110 cert_id = sc_obj.study_course111 res_cert = self.portal_catalog(id = cert_id)112 if len(res_cert) != 1:113 break114 certificate_brain = res_cert[0]115 certificate_obj = certificate_brain.getObject()116 cert_path = certificate_brain.getPath().split('/')117 fac_id = cert_path[-4]118 dep_id = cert_path[-3]117 # sc = getattr(real_object,'study_course',None) 118 # if sc is None: 119 # break 120 # sc_obj = sc.getContent() 121 # cert_id = sc_obj.study_course 122 # res_cert = self.portal_catalog(id = cert_id) 123 # if len(res_cert) != 1: 124 # break 125 # certificate_brain = res_cert[0] 126 # certificate_obj = certificate_brain.getObject() 127 # cert_path = certificate_brain.getPath().split('/') 128 # fac_id = cert_path[-4] 129 # dep_id = cert_path[-3] 119 130 # temporary self-healing function 120 131 # deprecated after reindexing the students_catalog … … 124 135 break 125 136 st_entry = res[0] 126 if st_entry.faculty != fac_id or\ 127 st_entry.department != dep_id or\ 128 st_entry.course != cert_id: 129 self.students_catalog.modifyRecord(id = student_id, 130 faculty = fac_id, 131 department = dep_id, 132 course = cert_id 133 ) 134 if real_object.portal_type == "StudentStudyLevel": 135 if real_object.meta_type != "StudentStudyLevel": 136 context_obj = getattr(certificate_obj,real_object.getId(),None) 137 # if st_entry.faculty != fac_id or\ 138 # st_entry.department != dep_id or\ 139 # st_entry.course != cert_id: 140 # self.students_catalog.modifyRecord(id = student_id, 141 # faculty = fac_id, 142 # department = dep_id, 143 # course = cert_id 144 # ) 145 if real_object.portal_type in ("StudentStudyLevel","StudentCourseResult"): 146 # res_cert = self.portal_catalog(id = st_entry.course) 147 # if len(res_cert) != 1: 148 # break 149 # certificate_brain = res_cert[0] 150 # certificate_obj = certificate_brain.getObject() 151 certificate_obj = getCertificateObject(self,st_entry) 152 if certificate_obj is None: 153 break 154 if real_object.meta_type.endswith('Folder'): # it is a proxy 155 object = real_object 137 156 else: 138 context_obj = getattr(certificate_obj,real_object.aq_parent.getId(),None) 157 object = real_object.aq_parent 158 if real_object.portal_type == "StudentStudyLevel": 159 level = object.getId() 160 elif real_object.portal_type == "StudentCourseResult": 161 level = object.aq_parent.getId() 162 context_obj = getattr(certificate_obj,level,None) 139 163 if context_obj is None: 140 164 #from pdb import set_trace;set_trace() … … 144 168 #we need some special processing since CourseAdvisers are only 145 169 #specified per StudyLevel 170 certificate_obj = getCertificateObject(self,st_entry) 171 if certificate_obj is None: 172 break 146 173 allowed = set(('CourseAdviser', 'SectionManager')) 147 174 for context_obj in certificate_obj.objectValues():
Note: See TracChangeset for help on using the changeset viewer.