Changeset 1775 for WAeUP_SRP/trunk
- Timestamp:
- 12 May 2007, 06:38:37 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r1751 r1775 93 93 portal_type = meta_type 94 94 security = ClassSecurityInfo() 95 96 security.declareProtected(ModifyPortalContent,"createDEStudents")###(97 def createDEStudents(self):98 """load Fulltime Studentdata from CSV values"""99 import transaction100 import random101 #from pdb import set_trace102 wftool = self.portal_workflow103 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()104 csv_d = {'jamb_reg_no': "RegNumber",105 'jamb_lastname': "Name",106 'session': "Session",107 'pume_tot_score': "PUDE SCORE",108 ##'jamb_score': "JambScore",109 'entry_mode': "EntryMode",110 'jamb_sex': "Sex",111 'jamb_state': "State",112 'jamb_first_cos': "AdminCourse",113 'faculty': "AdminFaculty",114 'course_code': "AdmitCoscode",115 'stud_status':"AdmitStatus",116 'department': "AdmitDept",117 'jamb_lga': "LGA",118 'app_email': "email",119 'app_mobile': "PhoneNumbers",120 }121 csv_fields = [f[1] for f in csv_d.items()]122 tr_count = 0123 total = 0124 #name = 'pume_results'125 name = 'DE_Admitted'126 no_import = []127 s = ','.join(['"%s"' % fn for fn in csv_fields])128 no_import.append('"Error",%s' % s)129 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields])130 no_certificate = "no certificate %s" % format131 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import))132 logger = logging.getLogger('Students.StudentsFolder.createDEStudents')133 logger.info('Start loading from %s.csv' % name)134 l = self.portal_catalog({'meta_type': "Certificate"})135 certs = {}136 cert_docs = {}137 for f in l:138 certs[f.getId] = f.getObject().getContent()139 try:140 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))141 except:142 logger.error('Error reading %s.csv' % name)143 return144 for jamb in result:145 jamb['Error'] = "Processing"146 logger.info(format % jamb)147 jamb_reg_no = jamb.get(csv_d['jamb_reg_no'])148 res = self.portal_catalog({'portal_type': "StudentApplication",149 'SearchableText': jamb_reg_no })150 if res:151 em = 'Student with RegNo %s already exists\n' % jamb_reg_no152 logger.info(em)153 jamb['Error'] = "Student exists"154 no_import.append(format % jamb)155 continue156 cert_id = makeCertificateCode(jamb.get(csv_d['course_code']))157 if cert_id not in certs.keys():158 em = 'No Certificate with ID %s \n' % cert_id159 logger.info(em)160 jamb['Error'] = "No Certificate %s" % cert_id161 no_import.append( format % jamb)162 continue163 jamb_reg_no =jamb.get(csv_d['jamb_reg_no'])164 cert_doc = certs[cert_id]165 catalog_entry = {}166 catalog_entry['jamb_reg_no'] = jamb_reg_no167 jamb_name = jamb.get(csv_d['jamb_lastname'])168 jamb_name.replace('>','')169 jamb_name.replace('<','')170 names = jamb_name.split()171 letter = names[-1][0].upper()172 sid = self.generateStudentId(letter)173 not_created = True174 while not_created:175 try:176 students_folder.invokeFactory('Student', sid)177 not_created = False178 except BadRequest:179 sid = self.generateStudentId(letter)180 catalog_entry['id'] = sid181 tr_count += 1182 logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars())183 student = getattr(self,sid)184 student.manage_setLocalRoles(sid, ['Owner',])185 student.invokeFactory('StudentPume','pume')186 dp = {'Title': 'Pume Data'}187 student.invokeFactory('StudentApplication','application')188 da = {'Title': 'Application Data'}189 da["jamb_lastname"] = jamb_name190 da_fields = ('jamb_reg_no',191 'jamb_sex',192 'entry_mode',193 #'jamb_score',194 'jamb_first_cos',195 'jamb_sex',196 'jamb_state',197 'jamb_lga',198 'app_email',199 'app_mobile',200 )201 for f in da_fields:202 da[f] = jamb.get(csv_d[f])203 catalog_entry['email'] = jamb.get(csv_d['app_email'])204 app = student.application205 app_doc = app.getContent()206 picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no)207 #import pdb;pdb.set_trace()208 if os.path.exists(picture):209 file = open(picture)210 if False:211 img = PIL.Image.open(file)212 img.thumbnail((150,200),213 resample=PIL.Image.ANTIALIAS)214 # We now need a buffer to write to. It can't be the same215 # as the inbuffer as the PNG writer will write over itself.216 outfile = StringIO()217 img.save(outfile, format=img.format)218 else:219 outfile = file.read()220 app_doc.manage_addFile('passport',221 file=outfile,222 title="%s.jpg" % jamb_reg_no)223 app.getContent().edit(mapping=da)224 app.manage_setLocalRoles(sid, ['Owner',])225 #wftool.doActionFor(app,'close')226 dp_fields = (227 #'pume_eng_score',228 #'pume_gen_score',229 'pume_tot_score',230 )231 dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded"232 pume = student.pume233 pume.getContent().edit(mapping=dp)234 #wftool.doActionFor(pume,'close')235 pume.manage_setLocalRoles(sid, ['Owner',])236 #student.getContent().createSubObjects()237 dp = {}238 if len(names) == 3:239 dp['firstname'] = names[0].capitalize()240 dp['middlename'] = names[1].capitalize()241 dp['lastname'] = names[2].capitalize()242 elif len(names) == 2:243 dp['firstname'] = names[0].capitalize()244 dp['middlename'] = ''245 dp['lastname'] = names[1].capitalize()246 else:247 dp['firstname'] = ''248 dp['middlename'] = ''249 dp['lastname'] = jamb_name250 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'251 catalog_entry['sex'] = dp['sex']252 catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp253 student.invokeFactory('StudentPersonal','personal')254 per = student.personal255 per_doc = per.getContent()256 per_doc.edit(mapping = dp)257 per.manage_setLocalRoles(sid, ['Owner',])258 if jamb.get(csv_d['stud_status']) == "Admitted":259 wftool.doActionFor(student,'pume_pass')260 wftool.doActionFor(student,'admit')261 else:262 wftool.doActionFor(student,'pume_fail')263 wftool.doActionFor(student,'reject_admission')264 continue265 #266 # Clearance267 #268 student.invokeFactory('StudentClearance','clearance')269 #wftool.doActionFor(student.clearance,'open')270 dp = {'Title': 'Clearance/Eligibility Record'}271 student.clearance.manage_setLocalRoles(sid, ['Owner',])272 #273 # Study Course274 #275 student.invokeFactory('StudentStudyCourse','study_course')276 study_course = student.study_course277 dsc = {}278 #from_certificate = ['title',279 # 'max_elect',280 # 'max_pass',281 # 'n_core',282 # 'nr_years',283 # 'probation_credits',284 # 'promotion_credits',285 # 'start_level',286 # ]287 #for f in from_certificate:288 # dsc[f] = getattr(cert_doc,f)289 #dsc['faculty'] = jamb.get(csv_d['faculty'])290 #dsc['department'] = jamb.get(csv_d['department'])291 catalog_entry['faculty'] = jamb.get(csv_d['faculty'])292 catalog_entry['department'] = jamb.get(csv_d['department'])293 catalog_entry['course'] = cert_id294 #catalog_entry['level'] = getattr(cert_doc,'start_level')295 catalog_entry['level'] = '200'296 dsc['study_course'] = cert_id297 dsc['current_level'] = '200'298 #dsc['entry_session'] = jamb.get(csv_d['session'])299 study_course.getContent().edit(mapping=dsc)300 self.students_catalog.addRecord(**catalog_entry)301 if tr_count > 10:302 if len(no_import) > 1:303 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(304 '\n'.join(no_import)+'\n')305 no_import = []306 em = '%d transactions commited\n' % tr_count307 transaction.commit()308 logger.info(em)309 total += tr_count310 tr_count = 0311 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(312 '\n'.join(no_import))313 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))314 ###)315 316 security.declareProtected(ModifyPortalContent,"createNewStudents")###(317 def createNewStudents(self):318 """load Fulltime Studentdata from CSV values"""319 import transaction320 import random321 #from pdb import set_trace322 wftool = self.portal_workflow323 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()324 csv_d = {'jamb_reg_no': "RegNumber",325 'jamb_lastname': "Name",326 'session': "Session",327 'pume_tot_score': "PUME SCORE",328 'jamb_score': "JambScore",329 'jamb_sex': "Sex",330 'jamb_state': "State",331 ## 'jamb_first_cos': "AdminCourse",332 'faculty': "AdminFaculty",333 'course_code': "AdmitCoscode",334 'stud_status':"AdmitStatus",335 'department': "AdmitDept",336 'jamb_lga': "LGA",337 'app_email': "email",338 'app_mobile': "PhoneNumbers",339 }340 csv_fields = [f[1] for f in csv_d.items()]341 tr_count = 0342 total = 0343 #name = 'pume_results'344 name = 'Admitted'345 no_import = []346 s = ','.join(['"%s"' % fn for fn in csv_fields])347 no_import.append('"Error",%s' % s)348 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields])349 no_certificate = "no certificate %s" % format350 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import))351 logger = logging.getLogger('Students.StudentsFolder.createNewStudents')352 logger.info('Start loading from %s.csv' % name)353 l = self.portal_catalog({'meta_type': "Certificate"})354 certs = {}355 cert_docs = {}356 for f in l:357 certs[f.getId] = f.getObject().getContent()358 try:359 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))360 except:361 logger.error('Error reading %s.csv' % name)362 return363 for jamb in result:364 jamb['Error'] = "Processing "365 logger.info(format % jamb)366 jamb_reg_no = jamb.get(csv_d['jamb_reg_no'])367 res = self.portal_catalog({'portal_type': "StudentApplication",368 'SearchableText': jamb_reg_no })369 if res:370 em = 'Student with RegNo %s already exists\n' % jamb_reg_no371 logger.info(em)372 jamb['Error'] = "Student exists"373 no_import.append(format % jamb)374 continue375 cert_id = makeCertificateCode(jamb.get(csv_d['course_code']))376 if cert_id not in certs.keys():377 em = 'No Certificate with ID %s \n' % cert_id378 logger.info(em)379 jamb['Error'] = "No Certificate %s" % cert_id380 no_import.append( format % jamb)381 continue382 res = self.portal_pumeresults(jamb_reg_no = jamb_reg_no)383 if len(res) == 1:384 self.portal_pumeresults.modifyRecord(jamb_reg_no = jamb_reg_no,385 status = jamb.get(csv_d['stud_status']),386 )387 jamb_reg_no =jamb.get(csv_d['jamb_reg_no'])388 cert_doc = certs[cert_id]389 catalog_entry = {}390 catalog_entry['jamb_reg_no'] = jamb_reg_no391 jamb_name = jamb.get(csv_d['jamb_lastname'])392 jamb_name.replace('>','')393 jamb_name.replace('<','')394 names = jamb_name.split()395 letter = names[-1][0].upper()396 sid = self.generateStudentId(letter)397 not_created = True398 while not_created:399 try:400 students_folder.invokeFactory('Student', sid)401 not_created = False402 except BadRequest:403 sid = self.generateStudentId(letter)404 catalog_entry['id'] = sid405 tr_count += 1406 logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s reg_no %(jamb_reg_no)s ' % vars())407 student = getattr(self,sid)408 student.manage_setLocalRoles(sid, ['Owner',])409 student.invokeFactory('StudentPume','pume')410 dp = {'Title': 'Pume Data'}411 student.invokeFactory('StudentApplication','application')412 da = {'Title': 'Application Data'}413 da["jamb_lastname"] = jamb_name414 da_fields = ('jamb_reg_no',415 'jamb_sex',416 #'jamb_state',417 'jamb_score',418 ## 'jamb_first_cos',419 'jamb_sex',420 'jamb_state',421 'jamb_lga',422 'app_email',423 'app_mobile',424 )425 for f in da_fields:426 da[f] = jamb.get(csv_d[f])427 catalog_entry['email'] = jamb.get(csv_d['app_email'])428 app = student.application429 app_doc = app.getContent()430 #import pdb;pdb.set_trace()431 picture ="%s/import/pictures/%s.jpg" % (i_home,picture_id)432 if os.path.exists(picture):433 file = open(picture)434 if False:435 img = PIL.Image.open(file)436 img.thumbnail((150,200),437 resample=PIL.Image.ANTIALIAS)438 # We now need a buffer to write to. It can't be the same439 # as the inbuffer as the PNG writer will write over itself.440 outfile = StringIO()441 img.save(outfile, format=img.format)442 else:443 outfile = file.read()444 app_doc.manage_addFile('passport',445 file=outfile,446 title="%s.jpg" % jamb_reg_no)447 app.getContent().edit(mapping=da)448 app.manage_setLocalRoles(sid, ['Owner',])449 #wftool.doActionFor(app,'close')450 dp_fields = (451 #'pume_eng_score',452 #'pume_gen_score',453 'pume_tot_score',454 )455 dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded"456 pume = student.pume457 pume.getContent().edit(mapping=dp)458 #wftool.doActionFor(pume,'close')459 pume.manage_setLocalRoles(sid, ['Owner',])460 #student.getContent().createSubObjects()461 dp = {}462 if len(names) == 3:463 dp['firstname'] = names[0].capitalize()464 dp['middlename'] = names[1].capitalize()465 dp['lastname'] = names[2].capitalize()466 elif len(names) == 2:467 dp['firstname'] = names[0].capitalize()468 dp['middlename'] = ''469 dp['lastname'] = names[1].capitalize()470 else:471 dp['firstname'] = ''472 dp['middlename'] = ''473 dp['lastname'] = jamb_name474 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'475 catalog_entry['sex'] = dp['sex']476 catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp477 student.invokeFactory('StudentPersonal','personal')478 per = student.personal479 per_doc = per.getContent()480 per_doc.edit(mapping = dp)481 per.manage_setLocalRoles(sid, ['Owner',])482 if jamb.get(csv_d['stud_status']) == "Admitted":483 wftool.doActionFor(student,'pume_pass')484 wftool.doActionFor(student,'admit')485 else:486 wftool.doActionFor(student,'pume_fail')487 wftool.doActionFor(student,'reject_admission')488 continue489 #490 # Clearance491 #492 student.invokeFactory('StudentClearance','clearance')493 #wftool.doActionFor(student.clearance,'open')494 dp = {'Title': 'Clearance/Eligibility Record'}495 student.clearance.manage_setLocalRoles(sid, ['Owner',])496 #497 # Study Course498 #499 student.invokeFactory('StudentStudyCourse','study_course')500 study_course = student.study_course501 dsc = {}502 #from_certificate = ['title',503 # 'max_elect',504 # 'max_pass',505 # 'n_core',506 # 'nr_years',507 # 'probation_credits',508 # 'promotion_credits',509 # 'start_level',510 # ]511 #for f in from_certificate:512 # dsc[f] = getattr(cert_doc,f)513 #dsc['faculty'] = jamb.get(csv_d['faculty'])514 #dsc['department'] = jamb.get(csv_d['department'])515 catalog_entry['faculty'] = jamb.get(csv_d['faculty'])516 catalog_entry['department'] = jamb.get(csv_d['department'])517 catalog_entry['course'] = cert_id518 #catalog_entry['level'] = getattr(cert_doc,'start_level')519 catalog_entry['level'] = '100'520 dsc['study_course'] = cert_id521 #dsc['entry_level'] = '100'522 #dsc['entry_session'] = jamb.get(csv_d['session'])523 study_course.getContent().edit(mapping=dsc)524 self.students_catalog.addRecord(**catalog_entry)525 if tr_count > 10:526 if len(no_import) > 0:527 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(528 '\n'.join(no_import) + "\n")529 no_import = []530 em = '%d transactions commited\n' % tr_count531 transaction.commit()532 logger.info(em)533 total += tr_count534 tr_count = 0535 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(536 '\n'.join(no_import))537 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))538 ###)539 95 540 96 security.declareProtected(ModifyPortalContent,"createStudents")###( … … 1315 871 ###) 1316 872 1317 security.declareProtected(ModifyPortalContent,"importPreviousSessionStudents")###(1318 def importPreviousSessionStudents(self):1319 """load and create previous session students from CSV"""1320 import transaction1321 import random1322 wftool = self.portal_workflow1323 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")1324 students_folder = self.portal_url.getPortalObject().campus.students1325 tr_count = 11326 total = 01327 #name = 'pume_results'1328 name = 'Previous'1329 keys = self.portal_schemas.import_student.keys()1330 keys += self.portal_schemas.import_student_level_data.keys()1331 not_imported = []1332 imported = []1333 certificates = {}1334 logger = logging.getLogger('Students.StudentsFolder.importPreviousSessionStudents')1335 try:1336 records = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))1337 except:1338 logger.error('Error reading %s.csv' % name)1339 return1340 start = True1341 for record in records:1342 if start:1343 start = False1344 logger.info('Start loading from %s.csv' % name)1345 false_keys = [k for k in record.keys() if k not in keys]1346 right_keys = [k for k in record.keys() if k in keys]1347 if false_keys:1348 logger.info('Fields %s not in schema' % false_keys)1349 s = ','.join(['"%s"' % k for k in right_keys])1350 imported.append(s)1351 not_imported.append('%s,"error"' % s)1352 format = ','.join(['"%%(%s)s"' % k for k in right_keys])1353 format_error = format + ',"%(error)s"'1354 study_course = makeCertificateCode(record.get('study_course'))1355 matric_no = record.get('matric_no')1356 student_res = self.students_catalog(matric_no = matric_no)1357 if student_res:1358 record['error'] = "Student exists"1359 not_imported.append(format_error % record)1360 continue1361 if study_course not in certificates.keys():1362 cert_res = self.portal_catalog(portal_type='Certificate',1363 id = study_course)1364 if not cert_res:1365 record['error'] = "No such studycourse"1366 not_imported.append(format_error % record)1367 continue1368 certificates[cert_res[0].id] = cert_res[0]1369 sid = self.generateStudentId('x',students_folder)1370 students_folder.invokeFactory('Student', sid)1371 #from pdb import set_trace;set_trace()1372 record['student_id'] = sid1373 student = getattr(self,sid)1374 student.manage_setLocalRoles(sid, ['Owner',])1375 student.invokeFactory('StudentApplication','application')1376 app = student.application1377 app_doc = app.getContent()1378 dict = {'Title': 'Application Data'}1379 dict["jamb_lastname"] = "%(firstname)s %(lastname)s %(middlename)s" % record1380 r2d = [1381 ('entry_mode','entry_mode'),1382 ('sex','jamb_sex'),1383 ('jamb_score','jamb_score'),1384 ('jamb_reg_no','jamb_reg_no'),1385 ]1386 for r,d in r2d:1387 dict[d] = record[r]1388 app_doc.edit(mapping=dict)1389 app.manage_setLocalRoles(sid, ['Owner',])1390 wftool.doActionFor(app,'close')1391 record['sex'] = record['sex'] == 'F'1392 student.invokeFactory('StudentPersonal','personal')1393 dict = {}1394 r2d = [('firstname','firstname'),1395 ('middlename','middlename'),1396 ('lastname','lastname'),1397 ('sex','sex'),1398 ('email','email'),1399 ('phone','phone'),1400 ('address','perm_address'),1401 ]1402 for r,d in r2d:1403 dict[d] = record[r]1404 per = student.personal1405 per_doc = per.getContent()1406 per_doc.edit(mapping = dict)1407 per.manage_setLocalRoles(sid, ['Owner',])1408 #1409 # Clearance1410 #1411 student.invokeFactory('StudentClearance','clearance')1412 #wftool.doActionFor(student.clearance,'open')1413 clearance = getattr(student,'clearance')1414 dict = {'Title': 'Clearance/Eligibility Record'}1415 clearance.getContent().edit(mapping = dict)1416 student.clearance.manage_setLocalRoles(sid, ['Owner',])1417 #1418 # Study Course1419 #1420 student.invokeFactory('StudentStudyCourse','study_course')1421 study_course = student.study_course1422 dict = {}1423 r2d = [('session','current_session'),1424 ('level','current_level'),1425 ('verdict','current_verdict'),1426 ('study_course','study_course'),1427 ]1428 for r,d in r2d:1429 dict[d] = record[r]1430 study_course.getContent().edit(mapping=dict)1431 #1432 # Study Level1433 #1434 level = record['level']1435 study_course.invokeFactory('StudentStudyLevel',level)1436 study_level = getattr(study_course,level)1437 dict = {}1438 r2d = [('session','session'),1439 ('level','code'),1440 ('verdict','verdict'),1441 ]1442 for r,d in r2d:1443 dict[d] = record[r]1444 study_level.getContent().edit(mapping=dict)1445 wftool.doActionFor(student,'return')1446 imported.append(format % record)1447 tr_count += 11448 record['tr_count'] = tr_count1449 record['total'] = total1450 logger.info('%(total)s+%(tr_count)s: Creating Student %(student_id)s %(matric_no)s %(jamb_reg_no)s' % record)1451 if tr_count > 1000:1452 if len(not_imported) > 0:1453 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(1454 '\n'.join(not_imported)+'\n')1455 not_imported = []1456 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(1457 '\n'.join(imported) + '\n')1458 imported = []1459 em = '%d transactions commited total %s' % (tr_count,total)1460 transaction.commit()1461 logger.info(em)1462 regs = []1463 total += tr_count1464 tr_count = 01465 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(1466 '\n'.join(imported))1467 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(1468 '\n'.join(not_imported))1469 em = '%d transactions commited total %d' % (tr_count,total)1470 logger.info(em)1471 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))1472 ###)1473 873 1474 874 security.declareProtected(ModifyPortalContent,"updateStudyCourse")###( -
WAeUP_SRP/trunk/Students.unused_methods.txt
r1571 r1775 644 644 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 645 645 ###) 646 647 648 security.declareProtected(ModifyPortalContent,"importPreviousSessionStudents")###( 649 def importPreviousSessionStudents(self): 650 """load and create previous session students from CSV""" 651 import transaction 652 import random 653 wftool = self.portal_workflow 654 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 655 students_folder = self.portal_url.getPortalObject().campus.students 656 tr_count = 1 657 total = 0 658 #name = 'pume_results' 659 name = 'Previous' 660 keys = self.portal_schemas.import_student.keys() 661 keys += self.portal_schemas.import_student_level_data.keys() 662 not_imported = [] 663 imported = [] 664 certificates = {} 665 logger = logging.getLogger('Students.StudentsFolder.importPreviousSessionStudents') 666 try: 667 records = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 668 except: 669 logger.error('Error reading %s.csv' % name) 670 return 671 start = True 672 for record in records: 673 if start: 674 start = False 675 logger.info('Start loading from %s.csv' % name) 676 false_keys = [k for k in record.keys() if k not in keys] 677 right_keys = [k for k in record.keys() if k in keys] 678 if false_keys: 679 logger.info('Fields %s not in schema' % false_keys) 680 s = ','.join(['"%s"' % k for k in right_keys]) 681 imported.append(s) 682 not_imported.append('%s,"error"' % s) 683 format = ','.join(['"%%(%s)s"' % k for k in right_keys]) 684 format_error = format + ',"%(error)s"' 685 study_course = makeCertificateCode(record.get('study_course')) 686 matric_no = record.get('matric_no') 687 student_res = self.students_catalog(matric_no = matric_no) 688 if student_res: 689 record['error'] = "Student exists" 690 not_imported.append(format_error % record) 691 continue 692 if study_course not in certificates.keys(): 693 cert_res = self.portal_catalog(portal_type='Certificate', 694 id = study_course) 695 if not cert_res: 696 record['error'] = "No such studycourse" 697 not_imported.append(format_error % record) 698 continue 699 certificates[cert_res[0].id] = cert_res[0] 700 sid = self.generateStudentId('x',students_folder) 701 students_folder.invokeFactory('Student', sid) 702 #from pdb import set_trace;set_trace() 703 record['student_id'] = sid 704 student = getattr(self,sid) 705 student.manage_setLocalRoles(sid, ['Owner',]) 706 student.invokeFactory('StudentApplication','application') 707 app = student.application 708 app_doc = app.getContent() 709 dict = {'Title': 'Application Data'} 710 dict["jamb_lastname"] = "%(firstname)s %(lastname)s %(middlename)s" % record 711 r2d = [ 712 ('entry_mode','entry_mode'), 713 ('sex','jamb_sex'), 714 ('jamb_score','jamb_score'), 715 ('jamb_reg_no','jamb_reg_no'), 716 ] 717 for r,d in r2d: 718 dict[d] = record[r] 719 app_doc.edit(mapping=dict) 720 app.manage_setLocalRoles(sid, ['Owner',]) 721 wftool.doActionFor(app,'close') 722 record['sex'] = record['sex'] == 'F' 723 student.invokeFactory('StudentPersonal','personal') 724 dict = {} 725 r2d = [('firstname','firstname'), 726 ('middlename','middlename'), 727 ('lastname','lastname'), 728 ('sex','sex'), 729 ('email','email'), 730 ('phone','phone'), 731 ('address','perm_address'), 732 ] 733 for r,d in r2d: 734 dict[d] = record[r] 735 per = student.personal 736 per_doc = per.getContent() 737 per_doc.edit(mapping = dict) 738 per.manage_setLocalRoles(sid, ['Owner',]) 739 # 740 # Clearance 741 # 742 student.invokeFactory('StudentClearance','clearance') 743 #wftool.doActionFor(student.clearance,'open') 744 clearance = getattr(student,'clearance') 745 dict = {'Title': 'Clearance/Eligibility Record'} 746 clearance.getContent().edit(mapping = dict) 747 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 748 # 749 # Study Course 750 # 751 student.invokeFactory('StudentStudyCourse','study_course') 752 study_course = student.study_course 753 dict = {} 754 r2d = [('session','current_session'), 755 ('level','current_level'), 756 ('verdict','current_verdict'), 757 ('study_course','study_course'), 758 ] 759 for r,d in r2d: 760 dict[d] = record[r] 761 study_course.getContent().edit(mapping=dict) 762 # 763 # Study Level 764 # 765 level = record['level'] 766 study_course.invokeFactory('StudentStudyLevel',level) 767 study_level = getattr(study_course,level) 768 dict = {} 769 r2d = [('session','session'), 770 ('level','code'), 771 ('verdict','verdict'), 772 ] 773 for r,d in r2d: 774 dict[d] = record[r] 775 study_level.getContent().edit(mapping=dict) 776 wftool.doActionFor(student,'return') 777 imported.append(format % record) 778 tr_count += 1 779 record['tr_count'] = tr_count 780 record['total'] = total 781 logger.info('%(total)s+%(tr_count)s: Creating Student %(student_id)s %(matric_no)s %(jamb_reg_no)s' % record) 782 if tr_count > 1000: 783 if len(not_imported) > 0: 784 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 785 '\n'.join(not_imported)+'\n') 786 not_imported = [] 787 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 788 '\n'.join(imported) + '\n') 789 imported = [] 790 em = '%d transactions commited total %s' % (tr_count,total) 791 transaction.commit() 792 logger.info(em) 793 regs = [] 794 total += tr_count 795 tr_count = 0 796 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 797 '\n'.join(imported)) 798 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 799 '\n'.join(not_imported)) 800 em = '%d transactions commited total %d' % (tr_count,total) 801 logger.info(em) 802 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 803 ###) 804 805 806 security.declareProtected(ModifyPortalContent,"createDEStudents")###( 807 def createDEStudents(self): 808 """load Fulltime Studentdata from CSV values""" 809 import transaction 810 import random 811 #from pdb import set_trace 812 wftool = self.portal_workflow 813 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject() 814 csv_d = {'jamb_reg_no': "RegNumber", 815 'jamb_lastname': "Name", 816 'session': "Session", 817 'pume_tot_score': "PUDE SCORE", 818 ##'jamb_score': "JambScore", 819 'entry_mode': "EntryMode", 820 'jamb_sex': "Sex", 821 'jamb_state': "State", 822 'jamb_first_cos': "AdminCourse", 823 'faculty': "AdminFaculty", 824 'course_code': "AdmitCoscode", 825 'stud_status':"AdmitStatus", 826 'department': "AdmitDept", 827 'jamb_lga': "LGA", 828 'app_email': "email", 829 'app_mobile': "PhoneNumbers", 830 } 831 csv_fields = [f[1] for f in csv_d.items()] 832 tr_count = 0 833 total = 0 834 #name = 'pume_results' 835 name = 'DE_Admitted' 836 no_import = [] 837 s = ','.join(['"%s"' % fn for fn in csv_fields]) 838 no_import.append('"Error",%s' % s) 839 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 840 no_certificate = "no certificate %s" % format 841 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import)) 842 logger = logging.getLogger('Students.StudentsFolder.createDEStudents') 843 logger.info('Start loading from %s.csv' % name) 844 l = self.portal_catalog({'meta_type': "Certificate"}) 845 certs = {} 846 cert_docs = {} 847 for f in l: 848 certs[f.getId] = f.getObject().getContent() 849 try: 850 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 851 except: 852 logger.error('Error reading %s.csv' % name) 853 return 854 for jamb in result: 855 jamb['Error'] = "Processing" 856 logger.info(format % jamb) 857 jamb_reg_no = jamb.get(csv_d['jamb_reg_no']) 858 res = self.portal_catalog({'portal_type': "StudentApplication", 859 'SearchableText': jamb_reg_no }) 860 if res: 861 em = 'Student with RegNo %s already exists\n' % jamb_reg_no 862 logger.info(em) 863 jamb['Error'] = "Student exists" 864 no_import.append(format % jamb) 865 continue 866 cert_id = makeCertificateCode(jamb.get(csv_d['course_code'])) 867 if cert_id not in certs.keys(): 868 em = 'No Certificate with ID %s \n' % cert_id 869 logger.info(em) 870 jamb['Error'] = "No Certificate %s" % cert_id 871 no_import.append( format % jamb) 872 continue 873 jamb_reg_no =jamb.get(csv_d['jamb_reg_no']) 874 cert_doc = certs[cert_id] 875 catalog_entry = {} 876 catalog_entry['jamb_reg_no'] = jamb_reg_no 877 jamb_name = jamb.get(csv_d['jamb_lastname']) 878 jamb_name.replace('>','') 879 jamb_name.replace('<','') 880 names = jamb_name.split() 881 letter = names[-1][0].upper() 882 sid = self.generateStudentId(letter) 883 not_created = True 884 while not_created: 885 try: 886 students_folder.invokeFactory('Student', sid) 887 not_created = False 888 except BadRequest: 889 sid = self.generateStudentId(letter) 890 catalog_entry['id'] = sid 891 tr_count += 1 892 logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars()) 893 student = getattr(self,sid) 894 student.manage_setLocalRoles(sid, ['Owner',]) 895 student.invokeFactory('StudentPume','pume') 896 dp = {'Title': 'Pume Data'} 897 student.invokeFactory('StudentApplication','application') 898 da = {'Title': 'Application Data'} 899 da["jamb_lastname"] = jamb_name 900 da_fields = ('jamb_reg_no', 901 'jamb_sex', 902 'entry_mode', 903 #'jamb_score', 904 'jamb_first_cos', 905 'jamb_sex', 906 'jamb_state', 907 'jamb_lga', 908 'app_email', 909 'app_mobile', 910 ) 911 for f in da_fields: 912 da[f] = jamb.get(csv_d[f]) 913 catalog_entry['email'] = jamb.get(csv_d['app_email']) 914 app = student.application 915 app_doc = app.getContent() 916 picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no) 917 #import pdb;pdb.set_trace() 918 if os.path.exists(picture): 919 file = open(picture) 920 if False: 921 img = PIL.Image.open(file) 922 img.thumbnail((150,200), 923 resample=PIL.Image.ANTIALIAS) 924 # We now need a buffer to write to. It can't be the same 925 # as the inbuffer as the PNG writer will write over itself. 926 outfile = StringIO() 927 img.save(outfile, format=img.format) 928 else: 929 outfile = file.read() 930 app_doc.manage_addFile('passport', 931 file=outfile, 932 title="%s.jpg" % jamb_reg_no) 933 app.getContent().edit(mapping=da) 934 app.manage_setLocalRoles(sid, ['Owner',]) 935 #wftool.doActionFor(app,'close') 936 dp_fields = ( 937 #'pume_eng_score', 938 #'pume_gen_score', 939 'pume_tot_score', 940 ) 941 dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded" 942 pume = student.pume 943 pume.getContent().edit(mapping=dp) 944 #wftool.doActionFor(pume,'close') 945 pume.manage_setLocalRoles(sid, ['Owner',]) 946 #student.getContent().createSubObjects() 947 dp = {} 948 if len(names) == 3: 949 dp['firstname'] = names[0].capitalize() 950 dp['middlename'] = names[1].capitalize() 951 dp['lastname'] = names[2].capitalize() 952 elif len(names) == 2: 953 dp['firstname'] = names[0].capitalize() 954 dp['middlename'] = '' 955 dp['lastname'] = names[1].capitalize() 956 else: 957 dp['firstname'] = '' 958 dp['middlename'] = '' 959 dp['lastname'] = jamb_name 960 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F' 961 catalog_entry['sex'] = dp['sex'] 962 catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp 963 student.invokeFactory('StudentPersonal','personal') 964 per = student.personal 965 per_doc = per.getContent() 966 per_doc.edit(mapping = dp) 967 per.manage_setLocalRoles(sid, ['Owner',]) 968 if jamb.get(csv_d['stud_status']) == "Admitted": 969 wftool.doActionFor(student,'pume_pass') 970 wftool.doActionFor(student,'admit') 971 else: 972 wftool.doActionFor(student,'pume_fail') 973 wftool.doActionFor(student,'reject_admission') 974 continue 975 # 976 # Clearance 977 # 978 student.invokeFactory('StudentClearance','clearance') 979 #wftool.doActionFor(student.clearance,'open') 980 dp = {'Title': 'Clearance/Eligibility Record'} 981 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 982 # 983 # Study Course 984 # 985 student.invokeFactory('StudentStudyCourse','study_course') 986 study_course = student.study_course 987 dsc = {} 988 #from_certificate = ['title', 989 # 'max_elect', 990 # 'max_pass', 991 # 'n_core', 992 # 'nr_years', 993 # 'probation_credits', 994 # 'promotion_credits', 995 # 'start_level', 996 # ] 997 #for f in from_certificate: 998 # dsc[f] = getattr(cert_doc,f) 999 #dsc['faculty'] = jamb.get(csv_d['faculty']) 1000 #dsc['department'] = jamb.get(csv_d['department']) 1001 catalog_entry['faculty'] = jamb.get(csv_d['faculty']) 1002 catalog_entry['department'] = jamb.get(csv_d['department']) 1003 catalog_entry['course'] = cert_id 1004 #catalog_entry['level'] = getattr(cert_doc,'start_level') 1005 catalog_entry['level'] = '200' 1006 dsc['study_course'] = cert_id 1007 dsc['current_level'] = '200' 1008 #dsc['entry_session'] = jamb.get(csv_d['session']) 1009 study_course.getContent().edit(mapping=dsc) 1010 self.students_catalog.addRecord(**catalog_entry) 1011 if tr_count > 10: 1012 if len(no_import) > 1: 1013 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 1014 '\n'.join(no_import)+'\n') 1015 no_import = [] 1016 em = '%d transactions commited\n' % tr_count 1017 transaction.commit() 1018 logger.info(em) 1019 total += tr_count 1020 tr_count = 0 1021 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 1022 '\n'.join(no_import)) 1023 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 1024 ###) 1025 1026 security.declareProtected(ModifyPortalContent,"createNewStudents")###( 1027 def createNewStudents(self): 1028 """load Fulltime Studentdata from CSV values""" 1029 import transaction 1030 import random 1031 #from pdb import set_trace 1032 wftool = self.portal_workflow 1033 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject() 1034 csv_d = {'jamb_reg_no': "RegNumber", 1035 'jamb_lastname': "Name", 1036 'session': "Session", 1037 'pume_tot_score': "PUME SCORE", 1038 'jamb_score': "JambScore", 1039 'jamb_sex': "Sex", 1040 'jamb_state': "State", 1041 ## 'jamb_first_cos': "AdminCourse", 1042 'faculty': "AdminFaculty", 1043 'course_code': "AdmitCoscode", 1044 'stud_status':"AdmitStatus", 1045 'department': "AdmitDept", 1046 'jamb_lga': "LGA", 1047 'app_email': "email", 1048 'app_mobile': "PhoneNumbers", 1049 } 1050 csv_fields = [f[1] for f in csv_d.items()] 1051 tr_count = 0 1052 total = 0 1053 #name = 'pume_results' 1054 name = 'Admitted' 1055 no_import = [] 1056 s = ','.join(['"%s"' % fn for fn in csv_fields]) 1057 no_import.append('"Error",%s' % s) 1058 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 1059 no_certificate = "no certificate %s" % format 1060 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import)) 1061 logger = logging.getLogger('Students.StudentsFolder.createNewStudents') 1062 logger.info('Start loading from %s.csv' % name) 1063 l = self.portal_catalog({'meta_type': "Certificate"}) 1064 certs = {} 1065 cert_docs = {} 1066 for f in l: 1067 certs[f.getId] = f.getObject().getContent() 1068 try: 1069 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 1070 except: 1071 logger.error('Error reading %s.csv' % name) 1072 return 1073 for jamb in result: 1074 jamb['Error'] = "Processing " 1075 logger.info(format % jamb) 1076 jamb_reg_no = jamb.get(csv_d['jamb_reg_no']) 1077 res = self.portal_catalog({'portal_type': "StudentApplication", 1078 'SearchableText': jamb_reg_no }) 1079 if res: 1080 em = 'Student with RegNo %s already exists\n' % jamb_reg_no 1081 logger.info(em) 1082 jamb['Error'] = "Student exists" 1083 no_import.append(format % jamb) 1084 continue 1085 cert_id = makeCertificateCode(jamb.get(csv_d['course_code'])) 1086 if cert_id not in certs.keys(): 1087 em = 'No Certificate with ID %s \n' % cert_id 1088 logger.info(em) 1089 jamb['Error'] = "No Certificate %s" % cert_id 1090 no_import.append( format % jamb) 1091 continue 1092 res = self.portal_pumeresults(jamb_reg_no = jamb_reg_no) 1093 if len(res) == 1: 1094 self.portal_pumeresults.modifyRecord(jamb_reg_no = jamb_reg_no, 1095 status = jamb.get(csv_d['stud_status']), 1096 ) 1097 jamb_reg_no =jamb.get(csv_d['jamb_reg_no']) 1098 cert_doc = certs[cert_id] 1099 catalog_entry = {} 1100 catalog_entry['jamb_reg_no'] = jamb_reg_no 1101 jamb_name = jamb.get(csv_d['jamb_lastname']) 1102 jamb_name.replace('>','') 1103 jamb_name.replace('<','') 1104 names = jamb_name.split() 1105 letter = names[-1][0].upper() 1106 sid = self.generateStudentId(letter) 1107 not_created = True 1108 while not_created: 1109 try: 1110 students_folder.invokeFactory('Student', sid) 1111 not_created = False 1112 except BadRequest: 1113 sid = self.generateStudentId(letter) 1114 catalog_entry['id'] = sid 1115 tr_count += 1 1116 logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s reg_no %(jamb_reg_no)s ' % vars()) 1117 student = getattr(self,sid) 1118 student.manage_setLocalRoles(sid, ['Owner',]) 1119 student.invokeFactory('StudentPume','pume') 1120 dp = {'Title': 'Pume Data'} 1121 student.invokeFactory('StudentApplication','application') 1122 da = {'Title': 'Application Data'} 1123 da["jamb_lastname"] = jamb_name 1124 da_fields = ('jamb_reg_no', 1125 'jamb_sex', 1126 #'jamb_state', 1127 'jamb_score', 1128 ## 'jamb_first_cos', 1129 'jamb_sex', 1130 'jamb_state', 1131 'jamb_lga', 1132 'app_email', 1133 'app_mobile', 1134 ) 1135 for f in da_fields: 1136 da[f] = jamb.get(csv_d[f]) 1137 catalog_entry['email'] = jamb.get(csv_d['app_email']) 1138 app = student.application 1139 app_doc = app.getContent() 1140 #import pdb;pdb.set_trace() 1141 picture ="%s/import/pictures/%s.jpg" % (i_home,picture_id) 1142 if os.path.exists(picture): 1143 file = open(picture) 1144 if False: 1145 img = PIL.Image.open(file) 1146 img.thumbnail((150,200), 1147 resample=PIL.Image.ANTIALIAS) 1148 # We now need a buffer to write to. It can't be the same 1149 # as the inbuffer as the PNG writer will write over itself. 1150 outfile = StringIO() 1151 img.save(outfile, format=img.format) 1152 else: 1153 outfile = file.read() 1154 app_doc.manage_addFile('passport', 1155 file=outfile, 1156 title="%s.jpg" % jamb_reg_no) 1157 app.getContent().edit(mapping=da) 1158 app.manage_setLocalRoles(sid, ['Owner',]) 1159 #wftool.doActionFor(app,'close') 1160 dp_fields = ( 1161 #'pume_eng_score', 1162 #'pume_gen_score', 1163 'pume_tot_score', 1164 ) 1165 dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded" 1166 pume = student.pume 1167 pume.getContent().edit(mapping=dp) 1168 #wftool.doActionFor(pume,'close') 1169 pume.manage_setLocalRoles(sid, ['Owner',]) 1170 #student.getContent().createSubObjects() 1171 dp = {} 1172 if len(names) == 3: 1173 dp['firstname'] = names[0].capitalize() 1174 dp['middlename'] = names[1].capitalize() 1175 dp['lastname'] = names[2].capitalize() 1176 elif len(names) == 2: 1177 dp['firstname'] = names[0].capitalize() 1178 dp['middlename'] = '' 1179 dp['lastname'] = names[1].capitalize() 1180 else: 1181 dp['firstname'] = '' 1182 dp['middlename'] = '' 1183 dp['lastname'] = jamb_name 1184 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F' 1185 catalog_entry['sex'] = dp['sex'] 1186 catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp 1187 student.invokeFactory('StudentPersonal','personal') 1188 per = student.personal 1189 per_doc = per.getContent() 1190 per_doc.edit(mapping = dp) 1191 per.manage_setLocalRoles(sid, ['Owner',]) 1192 if jamb.get(csv_d['stud_status']) == "Admitted": 1193 wftool.doActionFor(student,'pume_pass') 1194 wftool.doActionFor(student,'admit') 1195 else: 1196 wftool.doActionFor(student,'pume_fail') 1197 wftool.doActionFor(student,'reject_admission') 1198 continue 1199 # 1200 # Clearance 1201 # 1202 student.invokeFactory('StudentClearance','clearance') 1203 #wftool.doActionFor(student.clearance,'open') 1204 dp = {'Title': 'Clearance/Eligibility Record'} 1205 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 1206 # 1207 # Study Course 1208 # 1209 student.invokeFactory('StudentStudyCourse','study_course') 1210 study_course = student.study_course 1211 dsc = {} 1212 #from_certificate = ['title', 1213 # 'max_elect', 1214 # 'max_pass', 1215 # 'n_core', 1216 # 'nr_years', 1217 # 'probation_credits', 1218 # 'promotion_credits', 1219 # 'start_level', 1220 # ] 1221 #for f in from_certificate: 1222 # dsc[f] = getattr(cert_doc,f) 1223 #dsc['faculty'] = jamb.get(csv_d['faculty']) 1224 #dsc['department'] = jamb.get(csv_d['department']) 1225 catalog_entry['faculty'] = jamb.get(csv_d['faculty']) 1226 catalog_entry['department'] = jamb.get(csv_d['department']) 1227 catalog_entry['course'] = cert_id 1228 #catalog_entry['level'] = getattr(cert_doc,'start_level') 1229 catalog_entry['level'] = '100' 1230 dsc['study_course'] = cert_id 1231 #dsc['entry_level'] = '100' 1232 #dsc['entry_session'] = jamb.get(csv_d['session']) 1233 study_course.getContent().edit(mapping=dsc) 1234 self.students_catalog.addRecord(**catalog_entry) 1235 if tr_count > 10: 1236 if len(no_import) > 0: 1237 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 1238 '\n'.join(no_import) + "\n") 1239 no_import = [] 1240 em = '%d transactions commited\n' % tr_count 1241 transaction.commit() 1242 logger.info(em) 1243 total += tr_count 1244 tr_count = 0 1245 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 1246 '\n'.join(no_import)) 1247 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 1248 ###) -
WAeUP_SRP/trunk/WAeUPTool.py
r1774 r1775 687 687 {'id': 'personal', 688 688 'title': 'Personal Data', 689 'wf_state': ' close',689 'wf_state': 'open', 690 690 'fields': 691 691 ('firstname', … … 701 701 {'id': 'study_course', 702 702 'title': 'Study Course', 703 'wf_state': ' close',703 'wf_state': 'open', 704 704 'fields': 705 705 ('study_course', … … 709 709 'current_verdict', 710 710 ) 711 }, 712 'PaymentsFolder': 713 {'id': 'payments', 714 'title': 'Payments', 715 'wf_state': 'open', 716 'fields': 717 () 711 718 }, 712 719 } … … 741 748 sub_obj = getattr(student_obj,f2t[pt]['id']) 742 749 sub_doc = sub_obj.getContent() 743 self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj)750 #self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj) 744 751 d['Title'] = f2t[pt]['title'] 745 752 for field in f2t[pt]['fields']: … … 816 823 import transaction 817 824 import random 818 825 819 826 pm = self.portal_membership 820 member = pm.getAuthenticatedMember() 821 827 member = pm.getAuthenticatedMember() 828 822 829 logger = logging.getLogger('WAeUPTool.importData') 823 830 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
Note: See TracChangeset for help on using the changeset viewer.