Changeset 2501
- Timestamp:
- 2 Nov 2007, 09:49:14 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTool.py
r2500 r2501 1134 1134 ###) 1135 1135 1136 security.declareProtected(ModifyPortalContent,'mass_create_course ') ###(1137 def mass_create_course (self,mapping):1136 security.declareProtected(ModifyPortalContent,'mass_create_course_result') ###( 1137 def mass_create_course_result(self,mapping): 1138 1138 #import pdb;pdb.set_trace() 1139 if getattr(self,'_v_course_list',None) is None: 1140 self._v_course_list = [] 1141 if getattr(self,'_v_departments',None) is None: 1142 res = self.portal_catalog(portal_type = "Department") 1143 self._v_department_courses = {} 1144 for d in res: 1145 self._v_department_courses[d.getId] = getattr(d.getObject(),"courses",None) 1146 did = mapping['department_code'] 1147 d = self._v_department_courses.get(did,None) 1148 if d is None: 1149 return '', "No Department with ID: %s" % did 1139 if getattr(self,'_v_courses',None) is None: 1140 res = self.courses_catalog() 1141 self._v_courses = {} 1142 for brain in res: 1143 self._v_courses[brain.code] = brain 1150 1144 course_id = mapping.get('code') 1151 if course_id in self._v_course_list: 1152 return '', "Duplicate Course ID: %s" % did 1153 c = getattr(d,course_id,None) 1154 if c is not None: 1155 return '', "Duplicate Course ID: %s" % did 1145 if course_id not in self._v_courses.keys(): 1146 return '', "No course with ID: %s" % did 1147 id_key = '' 1148 for id_key in ('student_id','matric_no'): 1149 id_field = mapping.get(id_key,None) 1150 if id_field is not None: 1151 student_id = id_field 1152 break 1153 query = Eq(id_key,id_field) 1154 res = self.students_catalog.evalAdvancedQuery(query) 1155 if not res: 1156 return '', "No student with %(id_field)s: %(id_key)s" % vars() 1157 if id_field != "student_id": 1158 mapping['student_id'] = res[0].id 1159 mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % mapping 1160 for k in ('semester',): 1161 mapping[k] = getattr(self._v_courses[course_id],k) 1156 1162 try: 1157 d.invokeFactory('Course', course_id) 1158 except BadRequest,E: 1159 return '', "%s" % E 1160 self._v_course_list.append(course_id) 1161 c = getattr(d,course_id) 1162 c.getContent().edit(mapping=mapping) 1163 return course_id,'' 1164 ###) 1165 1163 self.course_results.addRecord(**mapping) 1164 except ValueError: 1165 return '', "course result already exists: %s" % key 1166 return key,'' 1167 ###) 1166 1168 1167 1169 security.declareProtected(ModifyPortalContent,'mass_edit_course_result') ###(
Note: See TracChangeset for help on using the changeset viewer.