Changeset 3233 for WAeUP_SRP/base
- Timestamp:
- 26 Feb 2008, 09:11:28 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPImport.py
r3219 r3233 85 85 self.layout = self.layout_tool._getOb(iname,None) 86 86 if self.schema is None: 87 errors.append(' No schema %s' % iname)87 errors.append('no schema %s' % iname) 88 88 if self.pending_schema is None: 89 89 self.pending_schema = self.schema 90 90 if self.layout is None: 91 errors.append(' No such layout %s' % iname)91 errors.append('no such layout %s' % iname) 92 92 self.data_keys = self.pending_schema.keys() 93 93 self.csv_keys = self.pending_schema.keys() … … 187 187 d = self._v_department_certificates.get(did,None) 188 188 if d is None: 189 msg = " No Department with ID: %s" % did189 msg = "no department with id: %s" % did 190 190 break 191 191 certificate_id = mapping.get('code') 192 192 if certificate_id in self._v_certificate_list: 193 msg = " Duplicate Certificate ID: %s" % did193 msg = "duplicate certificate id: %s" % did 194 194 break 195 195 c = getattr(d,certificate_id,None) 196 196 if c is not None: 197 msg = " Duplicate Certificate ID: %s" % did197 msg = "duplicate certificate id: %s" % did 198 198 break 199 199 try: … … 215 215 while True: 216 216 if not res: 217 msg = " No Certificate with ID: %s" % certificate_id217 msg = "no certificate with id: %s" % certificate_id 218 218 break 219 219 c = res[0].getObject() … … 245 245 department_courses = self._v_department_courses.get(department_id,None) 246 246 if department_courses is None: 247 msg = " No Department with ID: %(department_id)s" % vars()247 msg = "no department with id: %(department_id)s" % vars() 248 248 break 249 249 if course_id in self._v_course_list: 250 msg = " Duplicate Course ID: %(course_id)s" % vars()250 msg = "duplicate course id: %(course_id)s" % vars() 251 251 break 252 252 if course_id in department_courses: 253 msg = " Course %(course_id)s already exists in department %(department_id)s" % vars()253 msg = "course %(course_id)s already exists in department %(department_id)s" % vars() 254 254 break 255 255 try: … … 270 270 while True: 271 271 if not res: 272 msg = " No Course with ID: %s" % course_id272 msg = "no course with id: %s" % course_id 273 273 break 274 274 c = res[0].getObject() … … 284 284 plural_name = "%ss" % name 285 285 commit_after = 1000000 286 required_modes = ('create','edit' )286 required_modes = ('create','edit','remove') 287 287 288 288 def getStudentRecord(self,mapping): ###( 289 for id_key in ('student_id','matric_no'): 289 id_field_found = False 290 msg = '' 291 for id_key in ('id','matric_no'): 290 292 id_field = mapping.get(id_key,'') 291 293 if id_field: 294 if id_field_found: 295 msg = "%s must not be provided" % id_key 296 break 292 297 search_key = id_key 293 298 search_field = id_field 294 break 295 if search_key == "student_id": 296 search_key = 'id' 299 id_field_found = True 300 #if search_key == "student_id": 301 # search_key = 'id' 302 if not id_field_found: 303 msg = "neither id nor matric_no provided" 304 return None,msg 297 305 query = Eq(search_key,search_field) 298 306 res = self.students_catalog.evalAdvancedQuery(query) 299 307 student_record = None 300 msg = ''301 308 if res: 302 309 student_record = res[0] 303 310 if search_key == "matric_no": 304 mapping[' student_id'] = student_record.id305 elif search_key == " student_id":311 mapping['id'] = student_record.id 312 elif search_key == "id": 306 313 mapping['matric_no'] = student_record.matric_no 307 314 else: 308 msg = " No student with %(search_key)s %(search_field)s" % vars()315 msg = "no student with %(search_key)s %(search_field)s" % vars() 309 316 return student_record,msg 310 317 ###) … … 324 331 course_id = mapping.get('code') 325 332 if course_id not in self._v_courses.keys(): 326 msg = " No course with ID: %s" % course_id333 msg = "no course with id: %s" % course_id 327 334 break 328 335 student_record,msg = self.getStudentRecord(mapping) … … 374 381 if msg: 375 382 break 383 if not mapping.get('level_id',''): 384 msg = "level_id is missing" 385 break 386 if not mapping.get('code',''): 387 msg = "code is missing" 388 break 376 389 student_id = student_record.id 377 390 level_id = mapping['level_id'] … … 382 395 self.course_results.modifyRecord(**mapping) 383 396 except KeyError: 384 msg = " No course result to edit:%s" % key397 msg = "no course result with key %s" % key 385 398 return key,msg,mapping 386 399 ###) 387 400 388 401 def remove(self,mapping):###( 389 id_key = ''402 key = '' 390 403 msg = '' 391 404 while True: … … 393 406 if msg: 394 407 break 408 if not mapping.get('level_id',''): 409 msg = "level_id is missing" 410 break 411 if not mapping.get('code',''): 412 msg = "code is missing" 413 break 395 414 student_id = student_record.id 396 415 level_id = mapping['level_id'] … … 398 417 key = "%(student_id)s|%(level_id)s|%(code)s" % vars() 399 418 if self.course_results.getRecordByKey(key) is None: 400 msg = "no course -result with%(key)s" % vars()419 msg = "no course result with key %(key)s" % vars() 401 420 break 402 421 self.course_results.deleteRecord(key) … … 426 445 certificate_course_id = mapping.get('code') 427 446 if certificate_course_id not in self._v_courses: 428 msg = " No Course with ID: %s" % certificate_course_id447 msg = "no course with id: %s" % certificate_course_id 429 448 break 430 449 cert_id = mapping['certificate_code'] 431 450 cert = self._v_certificates.get(cert_id,None) 432 451 if cert is None: 433 msg = " No Certificate with ID: %s" % cert_id452 msg = "no certificate with id: %s" % cert_id 434 453 break 435 454 level_id = mapping.get('level') … … 439 458 level = getattr(cert,level_id,None) 440 459 elif hasattr(level,certificate_course_id): 441 msg = " Duplicate CertificateCourse ID: %(certificate_course_id)s " % vars()460 msg = "duplicate certificate course id: %(certificate_course_id)s " % vars() 442 461 msg += "in %(cert_id)s/ %(level_id)s" % vars() 443 462 break … … 467 486 faculty = self._v_faculties.get(faculty_id,None) 468 487 if faculty is None: 469 msg = " No Faculty with ID: %s" % faculty_id488 msg = "no faculty with id: %s" % faculty_id 470 489 break 471 490 else: … … 501 520 d = getattr(getattr(academics_folder,faculty_id),department_id,None) 502 521 except KeyError: 503 msg = " Department %s or Faculty %s wrong" % (department_id,faculty_id)522 msg = "department %s or faculty %s wrong" % (department_id,faculty_id) 504 523 break 505 524 if d is None or d.portal_type == "Faculty": 506 msg = " Department %s not found" % (department_id)525 msg = "department %s not found" % (department_id) 507 526 break 508 527 d.getContent().edit(mapping=mapping) … … 524 543 while True: 525 544 if faculty_id in academics_folder.objectIds(): 526 msg = " Faculty with ID: %s exists" % faculty_id545 msg = "faculty with id: %s exists" % faculty_id 527 546 break 528 547 logger.info('Creating Faculty %(code)s, %(title)s' % mapping) … … 546 565 f = getattr(academics_folder,faculty_id,None) 547 566 if f is None: 548 msg = " Faculty with ID: %s does not exist" % faculty_id567 msg = "faculty with id: %s does not exist" % faculty_id 549 568 f.getContent().edit(mapping=mapping) 550 569 break
Note: See TracChangeset for help on using the changeset viewer.