Changeset 1724
- Timestamp:
- 30 Apr 2007, 15:37:48 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTables.py
r1722 r1724 475 475 """ re-index everything we can find """ 476 476 students_folder = self.portal_url.getPortalObject().campus.students 477 478 cat = self._catalog479 paths = self._catalog.uids.items()480 477 if clear: 481 paths = tuple(paths) 482 cat.clear() 478 self._catalog.clear() 483 479 students = self.portal_catalog(portal_type="Student") 484 480 num_objects = len(students) … … 518 514 import_record.Lastname) 519 515 data['matric_no'] = import_record.Entryregno 520 ## sub_brains = self.portal_catalog(path = spath)521 ## if len(sub_brains) > 1:522 ## for sub_brain in sub_brains:523 ## if not sub_brain.portal_type in self.affected_types.keys():524 ## continue525 ## doc = sub_brain.getObject().getContent()526 ## for field in self.affected_types[sub_brain.portal_type]:527 ## if hasattr(self,'get_from_doc_%s' % field):528 ## data[field] = getattr(self,'get_from_doc_%s' % field)(doc)529 ## else:530 ## data[field] = getattr(doc,field)531 ## elif len(sub_brains) == 1:532 ## #import pdb;pdb.set_trace()533 ## import_res = self.returning_import(id = sid)534 ## if not import_res:535 ## continue536 ## import_record = import_res[0]537 ## data['matric_no'] = import_record.matric_no538 ## data['sex'] = import_record.Sex == 'F'539 ## data['name'] = "%s %s %s" % (import_record.Firstname,540 ## import_record.Middlename,541 ## import_record.Lastname)542 ## data['matric_no'] = import_record.Entryregno543 516 study_course = getattr(student_obj,'study_course',None) 544 517 current_level = data.get('level',None) … … 571 544 data['id'] = object.getId() 572 545 data['review_state'] = self.portal_workflow.getInfoFor(object,'review_state',None) 573 #from pdb import set_trace;set_trace()574 546 students_catalog.modifyRecord(**data) 575 547 return … … 676 648 def refreshCatalog(self, clear=0, pghandler=None): ###( 677 649 """ re-index everything we can find """ 650 if clear: 651 self._catalog.clear() 678 652 courses = self.portal_catalog(portal_type="Course") 679 653 num_objects = len(courses) 680 654 if pghandler: 681 655 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 656 #from pdb import set_trace;set_trace() 682 657 for i in xrange(num_objects): 683 658 if pghandler: pghandler.report(i) 684 659 course_brain = courses[i] 685 course_ object = course_brain.getObject()660 course_doc = course_brain.getObject().getContent() 686 661 pl = course_brain.getPath().split('/') 687 662 data = {} 663 for field in self.schema(): 664 data[field] = getattr(course_doc,field,None) 688 665 data[self.key] = course_brain.getId 689 data['faculty'] = pl[-4] 690 data['department'] = pl[-3] 691 doc = course_object.getContent() 692 self.modifyRecord(**data) 666 ai = pl.index('academics') 667 data['faculty'] = pl[ai +1] 668 data['department'] = pl[ai +2] 669 if clear: 670 self.addRecord(**data) 671 else: 672 self.modifyRecord(**data) 693 673 if pghandler: pghandler.finish() 694 674 ###) … … 709 689 course_id = object.getId() 710 690 data[self.key] = course_id 711 if event_type == "sys_add_object": 712 doc = object.getContent() 713 #from pdb import set_trace;set_trace() 714 for field in self.schema(): 715 if field != self.key: 716 data[field] = getattr(doc,field,None) 691 if event_type == "sys_add_object" and mt == 'CPS Proxy Folder': 717 692 try: 718 693 self.addRecord(**data) 719 694 except ValueError: 720 pass 695 return 696 course_id = object.getId() 697 doc = object.getContent() 698 if doc is None: 699 return 700 for field in self.schema(): 701 data[field] = getattr(doc,field,None) 702 data[self.key] = course_id 703 ai = rpl.index('academics') 704 data['faculty'] = rpl[ai +1] 705 data['department'] = rpl[ai +2] 706 self.modifyRecord(**data) 707 return 721 708 if event_type == "sys_del_object": 722 709 self.deleteRecord(course_id) 710 return 723 711 if event_type == "sys_modify_object" and mt == 'Course': 712 #from pdb import set_trace;set_trace() 724 713 for field in self.schema(): 725 if field != self.key: 726 data[field] = getattr(object,field,None) 714 data[field] = getattr(object,field,None) 727 715 course_id = object.aq_parent.getId() 728 716 data[self.key] = course_id 717 ai = rpl.index('academics') 718 data['faculty'] = rpl[ai +1] 719 data['department'] = rpl[ai +2] 729 720 self.modifyRecord(**data) 730 721 ###) -
WAeUP_SRP/trunk/skins/waeup_academics/getFacultiesInfo.py
r913 r1724 13 13 """ 14 14 request = context.REQUEST 15 def cmp_id(a,b): 16 s1 = "%(id)s" % a 17 s2 = "%(id)s" % b 18 if s1 == s2: 19 return 0 20 if s1 > s2: 21 return 1 22 return -1 15 23 16 24 wf = context.portal_workflow … … 32 40 row['is_editable'] = mtool.checkPermission('Modify portal content', fo) 33 41 items.append(row) 42 items.sort(cmp_id) 34 43 info['items'] = items 35 44 return info -
WAeUP_SRP/trunk/skins/waeup_default/id_rename.py
r681 r1724 6 6 Used within the folder_contents template. 7 7 """ 8 try: 9 from Products.zdb import set_trace 10 except: 11 def set_trace(): 12 pass 13 import logging 14 logger = logging.getLogger('Skins.id_rename') 15 mtool = context.portal_membership 16 member = mtool.getAuthenticatedMember() 8 17 9 18 REQUEST = context.REQUEST … … 14 23 % ('Courses cannot be renamed',))) 15 24 25 old_ids = REQUEST['ids'] 16 26 new_ids = REQUEST['new_ids'] 17 27 new_ids = [id.upper() for id in REQUEST['new_ids']] … … 20 30 if context.portal_type == "University": 21 31 here = context.academics 22 32 pt = context.portal_type 33 mt = context.meta_type 34 logger.info('%s starting renaming %s to %s' % (member,old_ids,new_ids)) 23 35 24 36 here.manage_renameObjects(REQUEST['ids'], new_ids, REQUEST) 37 if pt == 'University': 38 for faculty in old_ids: 39 students = context.students_catalog(faculty=faculty) 40 student_ids = [s.id for s in students] 41 data = {} 42 new_fid = new_ids[old_ids.index(faculty)] 43 data['faculty'] = new_fid 44 for sid in student_ids: 45 data['id'] = sid 46 context.students_catalog.modifyRecord(**data) 47 courses = context.courses_catalog(faculty=faculty) 48 courses_ids = [c.code for c in courses] 49 for cid in courses_ids: 50 data['code'] = cid 51 context.courses_catalogModify(**data) 52 elif pt == 'Faculty': 53 for department in old_ids: 54 students = context.students_catalog(department=department) 55 student_ids = [s.id for s in students] 56 data = {} 57 new_did = new_ids[old_ids.index(department)] 58 data['department'] = new_did 59 for sid in student_ids: 60 data['id'] = sid 61 context.students_catalog.modifyRecord(**data) 62 courses = context.courses_catalog(department=department) 63 courses_ids = [c.code for c in courses] 64 for cid in courses_ids: 65 data['code'] = cid 66 context.courses_catalogModify(**data) 67 logger.info('%s finished renaming %s to %s' % (member,old_ids,new_ids)) 25 68 26 69 return REQUEST.RESPONSE.redirect(here.absolute_url() + \ -
WAeUP_SRP/trunk/skins/waeup_default/id_rename_form.pt
r586 r1724 46 46 </div><!-- tal:condition="here/folder_rename_items" --> 47 47 48 <div tal:condition="not: here/ folder_rename_items">48 <div tal:condition="not: here/academics_rename_items"> 49 49 50 50 <p i18n:translate="help_no_items_to_rename"> -
WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py
r1716 r1724 34 34 if new_id is not None: 35 35 id = new_id 36 if type_name == " Course": # disable ifhandled by event36 if type_name == "xxxCourse": # disabled handled by event 37 37 d = {} 38 38 ptl = request.get('PATH_TRANSLATED').split('/') -
WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py
r1716 r1724 102 102 ) 103 103 logger.info('%s edited %s of %s' % (member,context.id,student_id)) 104 elif context.portal_type == " Course": # disable ifhandled by events104 elif context.portal_type == "xxxxCourse": # disabled handled by events 105 105 dd = {} 106 106 dd.update(ds) # ds is not a real dictionary
Note: See TracChangeset for help on using the changeset viewer.