- Timestamp:
- 8 May 2007, 15:01:11 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 7 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r1753 r1756 67 67 ) 68 68 69 student_field2types = { ###(70 'StudentApplication':71 {'id': 'application',72 'title': 'Application Data',73 'fields':74 ('jamb_reg_no',75 'entry_mode',76 #'entry_level',77 'entry_session',78 'jamb_score',79 'email',80 'phone',81 )82 },83 'StudentPume':84 {'id': 'pume',85 'title': 'Pume Data',86 'fields':87 ('pume_score',88 )89 },90 'StudentClearance':91 {'id': 'clearance',92 'title': 'Clearance Data',93 'fields':94 ('matric_no',95 #'entry_level',96 'entry_session',97 'nationality',98 'lga',99 )100 },101 'StudentPersonal':102 {'id': 'personal',103 'title': 'Personal Data',104 'fields':105 ('firstname',106 'middlename',107 'lastname',108 'sex',109 'email',110 'phone',111 )112 },113 'StudentStudyCourse':114 {'id': 'study_course',115 'title': 'Study Course',116 'fields':117 ('study_course',118 'current_level',119 'current_session',120 'current_verdict',121 )122 },123 }124 ###)125 126 69 def rwrite(self,s): 127 70 response = self.REQUEST.RESPONSE … … 292 235 return res[0] 293 236 return None 237 ###) 238 239 security.declareProtected(ModifyPortalContent,'get_csv_filenames') ###( 240 def get_csv_filenames(self): 241 "do it" 242 files = [file for file in os.listdir("%s/import/" % (i_home)) 243 if file.endswith('.csv') and file.find('imported') == -1] 244 return files 294 245 ###) 295 246 … … 696 647 ###) 697 648 649 student_field2types = { ###( 650 'StudentApplication': 651 {'id': 'application', 652 'title': 'Application Data', 653 'wf_state': 'close', 654 'fields': 655 ('jamb_reg_no', 656 'entry_mode', 657 #'entry_level', 658 'entry_session', 659 'jamb_score', 660 'email', 661 'phone', 662 ) 663 }, 664 'StudentPume': 665 {'id': 'pume', 666 'title': 'Pume Data', 667 'wf_state': 'close', 668 'fields': 669 ('pume_score', 670 ) 671 }, 672 'StudentClearance': 673 {'id': 'clearance', 674 'title': 'Clearance Data', 675 'wf_state': 'close', 676 'fields': 677 ('matric_no', 678 'nationality', 679 'lga', 680 ) 681 }, 682 'StudentPersonal': 683 {'id': 'personal', 684 'title': 'Personal Data', 685 'wf_state': 'close', 686 'fields': 687 ('firstname', 688 'middlename', 689 'lastname', 690 'sex', 691 'email', 692 'phone', 693 'perm_address', 694 ) 695 }, 696 'StudentStudyCourse': 697 {'id': 'study_course', 698 'title': 'Study Course', 699 'wf_state': 'close', 700 'fields': 701 ('study_course', 702 'current_level', 703 'current_session', 704 'current_mode', 705 'current_verdict', 706 ) 707 }, 708 } 709 ###) 710 711 698 712 security.declareProtected(ModifyPortalContent,'import_student') ###( 699 713 def import_student(self,dict): … … 714 728 students_folder.invokeFactory('Student', sid) 715 729 student_obj = getattr(students_folder,sid) 716 #password = self.generatePassword()717 #self.makeStudentMember(sid,password)718 730 f2t = self.student_field2types 719 731 for pt in f2t.keys(): … … 728 740 d['sex'] = dict.get('sex') == 'F' 729 741 sub_doc.edit(mapping = d) 730 self.portal_workflow.doActionFor(sub_obj, 'close',dest_container=sub_obj)742 self.portal_workflow.doActionFor(sub_obj,f2t[pt]['wf_state'],dest_container=sub_obj) 731 743 wfaction = 'return' 732 744 self.portal_workflow.doActionFor(student_obj,wfaction) … … 745 757 start = True 746 758 tr_count = 1 759 total_imported = 0 760 total_not_imported = 0 747 761 total = 0 748 762 iname = "import_%s" % name … … 751 765 schema = stool._getOb(iname) 752 766 if schema is None: 767 em = 'No such schema import_%s' % iname 753 768 logger.error('No such schema import_%s' % iname) 754 return 769 return em 755 770 layout = ltool._getOb(iname) 756 771 if layout is None: 757 logger.error('No such layout import_%s' % iname) 758 return 772 em = 'No such layout import_%s' % iname 773 logger.error(em) 774 return em 759 775 validators = {} 760 776 for widget in layout.keys(): … … 762 778 creator = getattr(self, 'import_%s' % name,None) 763 779 if creator is None: 764 logger.error('No creator function create_%s' % name) 765 return 780 em = 'No creator function create_%s' % name 781 logger.error(em) 782 return em 766 783 not_imported = [] 767 784 imported = [] … … 769 786 items = csv.DictReader(open("%s/import/%s.csv" % (i_home,filename),"rb")) 770 787 except: 771 logger.error('Error reading %s.csv' % filename) 772 return 788 em = 'Error reading %s.csv' % filename 789 logger.error(em) 790 return em 773 791 for item in items: 774 792 tr_count += 1 … … 788 806 return 789 807 s = ','.join(['"%s"' % fn for fn in import_keys]) 790 imported.append(s)791 not_imported.append('%s,"Error"' % s)808 open("%s/import/%s_imported%s.csv" % (i_home,filename,current),"a").write(s + '\n') 809 open("%s/import/%s_not_imported%s.csv" % (i_home,filename,current),"a").write('%s,"Error"' %s + '\n') 792 810 format = ','.join(['"%%(%s)s"' % fn for fn in import_keys]) 793 811 format_error = format + ',"%(Error)s"' 812 #from pdb import set_trace; set_trace() 813 format = '"%(id)s",'+ format 794 814 ds = DataStructure(data=item,datamodel=dm) 795 815 error_string = "" … … 798 818 error_string += " %s : %s" % (k,ds.getError(k)) 799 819 if not error_string: 800 item['id'],error = creator(dm) 820 item.update(dm) 821 item['id'],error = creator(item) 801 822 if error: 802 823 error_string += error … … 804 825 item['Error'] = error_string 805 826 not_imported.append(format_error % item) 827 total_not_imported += 1 806 828 else: 807 imported.append(format % dm) 829 imported.append(format % item) 830 total_imported += 1 831 total += 1 808 832 if tr_count > 1000: 809 833 if len(not_imported) > 0: … … 819 843 regs = [] 820 844 logger.info(em) 821 total += tr_count822 845 tr_count = 0 823 if len(imported) > 1:846 if len(imported) > 0: 824 847 open("%s/import/%s_imported%s.csv" % (i_home,filename,current),"a").write( 825 848 '\n'.join(imported)) 826 if len(not_imported) > 1:849 if len(not_imported) > 0: 827 850 open("%s/import/%s_not_imported%s.csv" % (i_home,filename,current),"a").write( 828 851 '\n'.join(not_imported)) 829 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 852 em = "Imported: %d, not imported: %d of total %d" % (total_imported,total_not_imported,total) 853 logger.info(em) 854 return em 830 855 ###) 831 856 -
WAeUP_SRP/trunk/profiles/default/layouts.xml
r1747 r1756 11 11 <object name="department" meta_type="CPS Layout"/> 12 12 <object name="faculty" meta_type="CPS Layout"/> 13 <object name="import" meta_type="CPS Layout"/> 13 14 <object name="import_student" meta_type="CPS Layout"/> 14 15 <object name="members" meta_type="CPS Layout"/> -
WAeUP_SRP/trunk/profiles/default/schemas.xml
r1534 r1756 16 16 <object name="student" meta_type="CPS Schema"/> 17 17 <object name="scratch_card_batch" meta_type="CPS Schema"/> 18 <object name="import" meta_type="CPS Schema"/> 18 19 <object name="import_student" meta_type="CPS Schema"/> 19 20 <object name="import_student_level_data" meta_type="CPS Schema"/> -
WAeUP_SRP/trunk/profiles/default/vocabularies.xml
r1728 r1756 6 6 <object name="acco_hall_reserved_rooms" meta_type="CPS Method Vocabulary"/> 7 7 <object name="courselevel" meta_type="CPS Vocabulary"/> 8 <object name="csv_names" meta_type="CPS Method Vocabulary"/> 8 9 <object name="entry_modes" meta_type="CPS Vocabulary"/> 9 10 <object name="exam_subjects" meta_type="CPS Vocabulary"/> 10 11 <object name="exam_types" meta_type="CPS Vocabulary"/> 11 12 <object name="exam_grades" meta_type="CPS Vocabulary"/> 13 <object name="import_names" meta_type="CPS Vocabulary"/> 12 14 <object name="institution_types_voc" meta_type="CPS Vocabulary"/> 13 15 <object name="get_departments_voc" meta_type="CPS Method Vocabulary"/> -
WAeUP_SRP/trunk/skins/waeup_default/sessions_voc.py
r1747 r1756 11 11 return l 12 12 13 if len(key) != 2:14 return 'unknown'15 13 try: 16 14 y = int(key) 17 15 except: 18 16 return 'unknown' 17 ##if len(key) != 2: 18 ## return 'unknown' 19 19 if y < 90: 20 20 cent = 2000 -
WAeUP_SRP/trunk/skins/waeup_design/main_template.pt
r1743 r1756 183 183 <td style="" class="shapeAreaShape5 colorBarAreaColor" valign="top"> 184 184 <div style="padding: 0.5em; text-align: left;" class="fontColordefaultfontcolors fontShapeaverage"> 185 <metal:block define-slot="header" /> 186 <metal:block define-slot="main" /> 187 <metal:block define-slot="sub" /> 185 <metal:block use-macro="here/generic_lib_portal_message/macros/portal_message" /> 186 <metal:block define-slot="header" /> 187 <metal:block define-slot="main" /> 188 <metal:block define-slot="sub" /> 188 189 </div> 189 190 </td> -
WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt
r1746 r1756 25 25 <td width="220px">Certificate Code:</td> 26 26 <td><span tal:content="info/doc/study_course" /></td> 27 </tr> 28 <tr> 29 <td width="220px">Current Session:</td> 30 <td><span tal:content="python:context.portal_vocabularies.sessions.get(info['doc'].current_session)" /></td> 27 31 </tr> 28 32 <tr>
Note: See TracChangeset for help on using the changeset viewer.