Changeset 1954
- Timestamp:
- 25 Jun 2007, 08:28:28 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTables.py
r1935 r1954 392 392 reindextypes = {} 393 393 reindex_special = [] 394 #import pdb;pdb.set_trace()395 394 for n in name: 396 395 if n in ("review_state","registered_courses"): … … 405 404 break 406 405 students = self.portal_catalog(portal_type="Student") 407 aq_portal = self.portal_catalog.evalAdvancedQuery 406 if hasattr(self,'portal_catalog_real'): 407 aq_portal = self.portal_catalog_real.evalAdvancedQuery 408 else: 409 aq_portal = self.portal_catalog.evalAdvancedQuery 408 410 num_objects = len(students) 409 411 if pghandler: … … 433 435 else: 434 436 data[field] = getattr(doc,field) 435 #from pdb import set_trace;set_trace()436 437 if not sub_objects and noattr: 437 438 import_res = self.returning_import(id = sid) … … 446 447 data['jamb_reg_no'] = import_record.Entryregno 447 448 if reindex_special and 'registered_courses' in reindex_special: 448 query = Eq('id','study_course') & Eq('path',student_brain.getPath()) 449 brains = aq_portal(query) 450 while brains: 451 study_course_path = brains[0].getPath() 452 level_brains = self.portal_catalog(path = study_course_path, 453 portal_type = "StudentStudyLevel") 454 if not level_brains: 455 break 456 modified = True 457 level_ids = [l.getId for l in level_brains] 458 level_ids.sort() 459 for l in level_brains: 460 if l.getId == level_ids[-1]: 461 level_path = l.getPath() 462 break 463 result_brains = self.portal_catalog(path = level_path, 464 portal_type = "StudentCourseResult") 465 course_ids = [cr.getId for cr in result_brains] 466 courses = [] 467 for c in course_ids: 468 if c.endswith('_co'): 469 courses.append(c[:-3]) 470 else: 471 courses.append(c) 472 data['registered_courses'] = courses 473 break 449 try: 450 study_course = getattr(student_object,"study_course") 451 level_ids = study_course.objectIds() 452 except: 453 continue 454 if not level_ids: 455 continue 456 modified = True 457 level_ids.sort() 458 course_ids = getattr(study_course,level_ids[-1]).objectIds() 459 courses = [] 460 for c in course_ids: 461 if c.endswith('_co'): 462 courses.append(c[:-3]) 463 else: 464 courses.append(c) 465 data['registered_courses'] = courses 474 466 if modified: 475 467 self.modifyRecord(**data) … … 543 535 pt = getattr(object,'portal_type',None) 544 536 mt = getattr(object,'meta_type',None) 545 students_catalog = self .students_catalog537 students_catalog = self 546 538 data = {} 547 539 if pt == 'Student' and\ … … 564 556 if event_type not in ("sys_add_object","sys_del_object"): 565 557 return 558 #import pdb;pdb.set_trace() 566 559 course_id = object.getId() 560 if course_id.endswith('_co'): 561 course_id = course_id[:-3] 567 562 student_id = object.absolute_url_path().split('/')[-4] 568 res = s elf(id = student_id)563 res = students_catalog(id = student_id) 569 564 if not res: 570 565 return 571 566 student_rec = res[0] 572 567 registered_courses = student_rec.registered_courses 573 if not registered_courses: 574 level_obj = object.aq_parent 575 courses = [] 576 for c in level_obj.objectIds(): 577 if c.endswith('_co'): 578 courses.append(c[:-3]) 579 else: 580 courses.append(c) 581 #from pdb import set_trace;set_trace() 582 registered_courses = courses 583 else: 584 if event_type == "sys_add_object": 585 registered_courses.append(course_id) 586 if event_type == "sys_del_object": 587 if course_id in registered_courses: 588 registered_courses.remove(course_id) 568 if event_type == "sys_add_object" and course_id not in registered_courses: 569 registered_courses.append(course_id) 570 elif event_type == "sys_del_object": 571 while course_id in registered_courses: 572 registered_courses.remove(course_id) 589 573 data['id'] = student_id 590 574 data['registered_courses'] = registered_courses
Note: See TracChangeset for help on using the changeset viewer.