Changeset 1319
- Timestamp:
- 18 Jan 2007, 23:09:04 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r1289 r1319 617 617 name = 'Admitted' 618 618 no_import = [] 619 s = ','.join(['" (%s)"' % fn for fn in csv_fields])619 s = ','.join(['"%s"' % fn for fn in csv_fields]) 620 620 no_import.append('"Error",%s' % s) 621 621 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) … … 841 841 if len(res) > 0: 842 842 regs = [s.matric_no for s in res] 843 #import pdb;pdb.set_trace() 843 844 for student in returning: 844 845 if start: 845 846 start = False 846 847 logger.info('start loading from %s.csv' % name) 847 s = ','.join(['" (%s)"' % fn for fn in student.keys()])848 s = ','.join(['"%s"' % fn for fn in student.keys()]) 848 849 imported.append(s) 849 850 no_import.append('%s,"Error"' % s) … … 851 852 format_error = format + ',"%(Error)s"' 852 853 no_certificate = "no certificate %s" % format 853 matric_no = student.get('matric_no').upper() 854 student['matric_no'] = matric_no 854 student['matric_no'] = matric_no = student.get('matric_no').upper() 855 student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper() 856 student['Permanent_Address'] = perm_address = student.get('Permanent Address') 855 857 if matric_no == '': 856 858 student['Error'] = "Empty matric_no" … … 869 871 table.addRecord(**student) 870 872 except ValueError: 871 #import pdb;pdb.set_trace()872 873 student['Error'] = "Duplicate" 873 874 no_import.append( format_error % student) … … 897 898 ###) 898 899 899 900 900 security.declareProtected(ModifyPortalContent,"fixAllEntryModeForReturning")###( 901 def fixAllEntryModeForReturning(self): 902 "read all Returning*.csv" 903 ipath = "%s/import/" % i_home 904 names = os.listdir(ipath) 905 #import pdb;pdb.set_trace() 906 for name in names: 907 head,tail = os.path.splitext(name) 908 if head.startswith('Returning')\ 909 and tail == '.csv'\ 910 and name.find('imported') < 0: 911 self.fixEntryModeForReturning(csv_file=head) 912 913 security.declareProtected(ModifyPortalContent,"fixEntryModeForReturning")###( 914 def fixEntryModeForReturning(self,csv_file=None): 915 """load Returning Studentdata from CSV values""" 916 import transaction 917 import random 918 wftool = self.portal_workflow 919 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 920 students_folder = self.portal_url.getPortalObject().campus.students 921 tr_count = 1 922 total = 0 923 if csv_file is None: 924 name = 'Returning' 925 else: 926 name = csv_file 927 table = self.returning_import 928 st_cat = self.students_catalog 929 no_import = [] 930 logger = logging.getLogger('getEntryMode.%s' % name) 931 try: 932 returning = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 933 except: 934 logger.error('Error reading %s.csv' % name) 935 return 936 start = True 937 for student in returning: 938 if start: 939 start = False 940 logger.info('start loading from %s.csv' % name) 941 s = ','.join(['"(%s)"' % fn for fn in student.keys()]) 942 no_import.append('%s,"Error"' % s) 943 format = ','.join(['"%%(%s)s"' % fn for fn in student.keys()]) 944 format_error = format + ',"%(Error)s"' 945 matric_no = student.get('matric_no') 946 if not matric_no: 947 continue 948 matric_no = matric_no.upper() 949 student['matric_no'] = matric_no 950 if matric_no == '': 951 continue 952 if not table(matric_no = matric_no): 953 student['Error'] = "Not imported yet" 954 no_import.append( format_error % student) 955 continue 956 student_id = None 957 app = None 958 per = None 959 if st_cat(matric_no = matric_no): 960 student_id = st_cat(matric_no = matric_no)[0].id 961 app = getattr(getattr(students_folder,student_id),'application',None) 962 if app is not None: 963 app_doc = app.getContent() 964 per = getattr(getattr(students_folder,student_id),'personal',None) 965 if per is not None: 966 per_doc = per.getContent() 967 student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper() 968 student['Permanent_Address'] = perm_address = student.get('Permanent Address') 969 entry_mode = student['Mode of Entry'] 970 if not entry_mode: 971 student['Error'] = "'Mode of Entry' empty" 972 no_import.append( format_error % student) 973 continue 974 try: 975 table.modifyRecord(matric_no = matric_no, 976 Mode_of_Entry = entry_mode, 977 Permanent_Address = perm_address) 978 except KeyError: 979 student['Error'] = "Not found in returning_import" 980 no_import.append( format_error % student) 981 continue 982 if student_id is not None: 983 try: 984 st_cat.modifyRecord(id = student_id, 985 entry_mode=entry_mode) 986 except KeyError: 987 student['Error'] = "Not found in students_catalog" 988 no_import.append( format_error % student) 989 continue 990 if app is not None: 991 da = {} 992 da['entry_mode'] = entry_mode 993 app_doc.edit(mapping=da) 994 if per is not None: 995 dp = {} 996 dp['perm_address'] = entry_mode 997 per_doc.edit(mapping=dp) 998 tr_count += 1 999 if tr_count > 1000: 1000 if len(no_import) > 0: 1001 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 1002 '\n'.join(no_import) + '\n') 1003 no_import = [] 1004 em = '%d transactions commited total %s\n' % (tr_count,total) 1005 transaction.commit() 1006 regs = [] 1007 logger.info(em) 1008 total += tr_count 1009 tr_count = 0 1010 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 1011 '\n'.join(no_import)) 1012 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 1013 ###) 901 1014 902 1015 security.declareProtected(ModifyPortalContent,"updateReturningStudents")###( … … 993 1106 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 994 1107 ###) 995 996 997 998 1108 999 1109 security.declareProtected(ModifyPortalContent,"importResults")###( -
WAeUP_SRP/trunk/WAeUPTool.py
r1287 r1319 182 182 student = res[0] 183 183 logger.info('"%s", "creating Datastructure"' % student_id) 184 185 184 #student should not be allowed to perform this transition 186 185 #wftool = self.portal_workflow 187 186 #wftool.doActionFor(student,'return') 188 189 187 certcode_org = student.Coursemajorcode 190 188 certcode = makeCertificateCode(certcode_org) -
WAeUP_SRP/trunk/profiles/default/layouts.xml
r1274 r1319 33 33 <object name="student_search" meta_type="CPS Layout"/> 34 34 <object name="student_study_level" meta_type="CPS Layout"/> 35 <object name="student_transfer" meta_type="CPS Layout"/> 35 36 <object name="study_level" meta_type="CPS Layout"/> 36 37 <object name="university" meta_type="CPS Layout"/> -
WAeUP_SRP/trunk/profiles/default/students_catalog.xml
r1291 r1319 25 25 <indexed_attr value="faculty"/> 26 26 </index> 27 <index name="entry_mode" meta_type="KeywordIndex"> 28 <indexed_attr value="entry_mode"/> 29 </index> 27 30 <index name="department" meta_type="KeywordIndex"> 28 31 <indexed_attr value="department"/> -
WAeUP_SRP/trunk/profiles/default/vocabularies.xml
r1002 r1319 21 21 <object name="pin_prefixes" meta_type="CPS Vocabulary"/> 22 22 <object name="student_search_mode" meta_type="CPS Vocabulary"/> 23 <object name="student_transfer_types" meta_type="CPS Vocabulary"/> 23 24 <object name="scratch_card_search_mode" meta_type="CPS Vocabulary"/> 24 25 <object name="student_status_voc" meta_type="CPS Vocabulary"/>
Note: See TracChangeset for help on using the changeset viewer.