Changeset 1700
- Timestamp:
- 23 Apr 2007, 21:16:34 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r1649 r1700 538 538 ###) 539 539 540 security.declareProtected(ModifyPortalContent,"createNewStudents")###( 541 def createParttimeStudents(self): 542 """load Parttime Studentdata from CSV values""" 543 import transaction 544 import random 545 #from pdb import set_trace 546 wftool = self.portal_workflow 547 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject() 548 csv_d = {'jamb_reg_no': "Reg_No", 549 'jamb_firstname': "Firstname", 550 'jamb_middlename': "Middlename", 551 'jamb_lastname': "Lastname", 552 'jamb_sex': "Sex", 553 'entry_mode': 'Entry_mode', 554 'jamb_age': "Age", 555 'jamb_state': "State", 556 ## 'jamb_first_cos': "AdminCourse", 557 'faculty': "AdminFaculty", 558 'course_code': "AdmitCoscode", 559 'stud_status':"AdmitStatus", 560 'department': "AdmitDept", 561 'jamb_lga': "LGA", 562 'app_email': "email", 563 'app_mobile': "PhoneNumbers", 564 } 565 csv_fields = [f[1] for f in csv_d.items()] 566 tr_count = 0 567 total = 0 568 #name = 'pume_results' 569 name = 'Admitted' 570 no_import = [] 571 s = ','.join(['"%s"' % fn for fn in csv_fields]) 572 no_import.append('"Error",%s' % s) 573 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 574 no_certificate = "no certificate %s" % format 575 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import)) 576 logger = logging.getLogger('Students.StudentsFolder.createNewStudents') 577 logger.info('Start loading from %s.csv' % name) 578 l = self.portal_catalog({'meta_type': "Certificate"}) 579 certs = {} 580 cert_docs = {} 581 for f in l: 582 certs[f.getId] = f.getObject().getContent() 583 try: 584 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 585 except: 586 logger.error('Error reading %s.csv' % name) 587 return 588 for jamb in result: 589 jamb['Error'] = "Processing " 590 logger.info(format % jamb) 591 jamb_reg_no = jamb.get(csv_d['jamb_reg_no']) 592 res = self.portal_catalog({'portal_type': "StudentApplication", 593 'SearchableText': jamb_reg_no }) 594 if res: 595 em = 'Student with RegNo %s already exists\n' % jamb_reg_no 596 logger.info(em) 597 jamb['Error'] = "Student exists" 598 no_import.append(format % jamb) 599 continue 600 cert_id = makeCertificateCode(jamb.get(csv_d['course_code'])) 601 if cert_id not in certs.keys(): 602 em = 'No Certificate with ID %s \n' % cert_id 603 logger.info(em) 604 jamb['Error'] = "No Certificate %s" % cert_id 605 no_import.append( format % jamb) 606 continue 607 res = self.portal_pumeresults(jamb_reg_no = jamb_reg_no) 608 if len(res) == 1: 609 self.portal_pumeresults.modifyRecord(jamb_reg_no = jamb_reg_no, 610 status = jamb.get(csv_d['stud_status']), 611 ) 612 jamb_reg_no =jamb.get(csv_d['jamb_reg_no']) 613 cert_doc = certs[cert_id] 614 catalog_entry = {} 615 catalog_entry['jamb_reg_no'] = jamb_reg_no 616 jamb_name = jamb.get(csv_d['jamb_lastname']) 617 jamb_name.replace('>','') 618 jamb_name.replace('<','') 619 names = jamb_name.split() 620 letter = names[-1][0].upper() 621 sid = self.generateStudentId(letter) 622 not_created = True 623 while not_created: 624 try: 625 students_folder.invokeFactory('Student', sid) 626 not_created = False 627 except BadRequest: 628 sid = self.generateStudentId(letter) 629 catalog_entry['id'] = sid 630 tr_count += 1 631 logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars()) 632 student = getattr(self,sid) 633 student.manage_setLocalRoles(sid, ['Owner',]) 634 student.invokeFactory('StudentPume','pume') 635 dp = {'Title': 'Pume Data'} 636 student.invokeFactory('StudentApplication','application') 637 da = {'Title': 'Application Data'} 638 da["jamb_lastname"] = jamb_name 639 da_fields = ('jamb_reg_no', 640 'jamb_sex', 641 #'jamb_state', 642 'jamb_score', 643 ## 'jamb_first_cos', 644 'jamb_sex', 645 'jamb_state', 646 'jamb_lga', 647 'app_email', 648 'app_mobile', 649 ) 650 for f in da_fields: 651 da[f] = jamb.get(csv_d[f]) 652 catalog_entry['email'] = jamb.get(csv_d['app_email']) 653 app = student.application 654 app_doc = app.getContent() 655 picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no) 656 #import pdb;pdb.set_trace() 657 if os.path.exists(picture): 658 file = open(picture) 659 if False: 660 img = PIL.Image.open(file) 661 img.thumbnail((150,200), 662 resample=PIL.Image.ANTIALIAS) 663 # We now need a buffer to write to. It can't be the same 664 # as the inbuffer as the PNG writer will write over itself. 665 outfile = StringIO() 666 img.save(outfile, format=img.format) 667 else: 668 outfile = file.read() 669 app_doc.manage_addFile('passport', 670 file=outfile, 671 title="%s.jpg" % jamb_reg_no) 672 app.getContent().edit(mapping=da) 673 app.manage_setLocalRoles(sid, ['Owner',]) 674 #wftool.doActionFor(app,'close') 675 dp_fields = ( 676 #'pume_eng_score', 677 #'pume_gen_score', 678 'pume_tot_score', 679 ) 680 dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded" 681 pume = student.pume 682 pume.getContent().edit(mapping=dp) 683 #wftool.doActionFor(pume,'close') 684 pume.manage_setLocalRoles(sid, ['Owner',]) 685 #student.getContent().createSubObjects() 686 dp = {} 687 if len(names) == 3: 688 dp['firstname'] = names[0].capitalize() 689 dp['middlename'] = names[1].capitalize() 690 dp['lastname'] = names[2].capitalize() 691 elif len(names) == 2: 692 dp['firstname'] = names[0].capitalize() 693 dp['middlename'] = '' 694 dp['lastname'] = names[1].capitalize() 695 else: 696 dp['firstname'] = '' 697 dp['middlename'] = '' 698 dp['lastname'] = jamb_name 699 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F' 700 catalog_entry['sex'] = dp['sex'] 701 catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp 702 student.invokeFactory('StudentPersonal','personal') 703 per = student.personal 704 per_doc = per.getContent() 705 per_doc.edit(mapping = dp) 706 per.manage_setLocalRoles(sid, ['Owner',]) 707 if jamb.get(csv_d['stud_status']) == "Admitted": 708 wftool.doActionFor(student,'pume_pass') 709 wftool.doActionFor(student,'admit') 710 else: 711 wftool.doActionFor(student,'pume_fail') 712 wftool.doActionFor(student,'reject_admission') 713 continue 714 # 715 # Clearance 716 # 717 student.invokeFactory('StudentClearance','clearance') 718 #wftool.doActionFor(student.clearance,'open') 719 dp = {'Title': 'Clearance/Eligibility Record'} 720 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 721 # 722 # Study Course 723 # 724 student.invokeFactory('StudentStudyCourse','study_course') 725 study_course = student.study_course 726 dsc = {} 727 #from_certificate = ['title', 728 # 'max_elect', 729 # 'max_pass', 730 # 'n_core', 731 # 'nr_years', 732 # 'probation_credits', 733 # 'promotion_credits', 734 # 'start_level', 735 # ] 736 #for f in from_certificate: 737 # dsc[f] = getattr(cert_doc,f) 738 #dsc['faculty'] = jamb.get(csv_d['faculty']) 739 #dsc['department'] = jamb.get(csv_d['department']) 740 catalog_entry['faculty'] = jamb.get(csv_d['faculty']) 741 catalog_entry['department'] = jamb.get(csv_d['department']) 742 catalog_entry['course'] = cert_id 743 #catalog_entry['level'] = getattr(cert_doc,'start_level') 744 catalog_entry['level'] = '100' 745 dsc['study_course'] = cert_id 746 dsc['entry_level'] = '100' 747 #dsc['entry_session'] = jamb.get(csv_d['session']) 748 study_course.getContent().edit(mapping=dsc) 749 self.students_catalog.addRecord(**catalog_entry) 750 if tr_count > 10: 751 if len(no_import) > 0: 752 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 753 '\n'.join(no_import) + "\n") 754 no_import = [] 755 em = '%d transactions commited\n' % tr_count 756 transaction.commit() 757 logger.info(em) 758 total += tr_count 759 tr_count = 0 760 open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write( 761 '\n'.join(no_import)) 762 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 763 ###) 764 540 765 security.declareProtected(ModifyPortalContent,"importReturningStudents")###( 541 766 def importReturningStudents(self): … … 1088 1313 #result['Error'] = "No Course" 1089 1314 #logger.info(format_error % result) 1090 result['key'] = key1091 try:1092 table.addRecord(**result)1093 except ValueError:1094 #import pdb;pdb.set_trace()1095 result['Error'] = "Duplicate"1096 no_import.append( format_error % result)1097 continue1098 1315 regs.append(key) 1099 1316 imported.append(format % result) … … 1125 1342 '\n'.join(no_course_list)) 1126 1343 em = '%d transactions commited total %s\n courses not found %s' % (tr_count,total,course_count) 1344 logger.info(em) 1345 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 1346 ###) 1347 1348 security.declareProtected(ModifyPortalContent,"importPreviousSessionStudents")###( 1349 def importPreviousSessionStudents(self): 1350 """load and create previous session students from CSV""" 1351 import transaction 1352 import random 1353 wftool = self.portal_workflow 1354 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 1355 students_folder = self.portal_url.getPortalObject().campus.students 1356 tr_count = 1 1357 total = 0 1358 #name = 'pume_results' 1359 name = 'Previous' 1360 keys = self.portal_schemas.import_student.keys() 1361 keys += self.portal_schemas.import_student_level_data.keys() 1362 not_imported = [] 1363 imported = [] 1364 certificates = {} 1365 logger = logging.getLogger('Students.StudentsFolder.importPreviousSessionStudents') 1366 try: 1367 records = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 1368 except: 1369 logger.error('Error reading %s.csv' % name) 1370 return 1371 start = True 1372 for record in records: 1373 if start: 1374 start = False 1375 logger.info('Start loading from %s.csv' % name) 1376 false_keys = [k for k in record.keys() if k not in keys] 1377 right_keys = [k for k in record.keys() if k in keys] 1378 if false_keys: 1379 logger.info('Fields %s not in schema' % false_keys) 1380 s = ','.join(['"%s"' % k for k in right_keys]) 1381 imported.append(s) 1382 not_imported.append('%s,"error"' % s) 1383 format = ','.join(['"%%(%s)s"' % k for k in right_keys]) 1384 format_error = format + ',"%(error)s"' 1385 study_course = record.get('study_course') 1386 matric_no = record.get('matric_no') 1387 student_res = self.students_catalog(matric_no = matric_no) 1388 if student_res: 1389 record['error'] = "Student exists" 1390 not_imported.append(format_error % record) 1391 continue 1392 if study_course not in certificates.keys(): 1393 cert_res = self.portal_catalog(portal_type='Certificate', 1394 id = study_course) 1395 if not cert_res: 1396 record['error'] = "No such studycourse" 1397 not_imported.append(format_error % record) 1398 continue 1399 certificates[cert_res[0].id] = cert_res[0] 1400 sid = self.generateStudentId('x',students_folder) 1401 students_folder.invokeFactory('Student', sid) 1402 #from pdb import set_trace;set_trace() 1403 record['student_id'] = sid 1404 student = getattr(self,sid) 1405 student.manage_setLocalRoles(sid, ['Owner',]) 1406 student.invokeFactory('StudentApplication','application') 1407 app = student.application 1408 app_doc = app.getContent() 1409 dict = {'Title': 'Application Data'} 1410 dict["jamb_lastname"] = "%(firstname)s %(lastname)s %(middlename)s" % record 1411 r2d = [ 1412 ('entry_mode','entry_mode'), 1413 ('sex','jamb_sex'), 1414 ('jamb_score','jamb_score'), 1415 ('jamb_reg_no','jamb_reg_no'), 1416 ] 1417 for r,d in r2d: 1418 dict[d] = record[r] 1419 app_doc.edit(mapping=dict) 1420 app.manage_setLocalRoles(sid, ['Owner',]) 1421 wftool.doActionFor(app,'close') 1422 record['sex'] = record['sex'] == 'F' 1423 student.invokeFactory('StudentPersonal','personal') 1424 dict = {} 1425 r2d = [('firstname','firstname'), 1426 ('middlename','middlename'), 1427 ('lastname','lastname'), 1428 ('sex','sex'), 1429 ('email','email'), 1430 ('phone','phone'), 1431 ('address','perm_address'), 1432 ] 1433 for r,d in r2d: 1434 dict[d] = record[r] 1435 per = student.personal 1436 per_doc = per.getContent() 1437 per_doc.edit(mapping = dict) 1438 per.manage_setLocalRoles(sid, ['Owner',]) 1439 # 1440 # Clearance 1441 # 1442 student.invokeFactory('StudentClearance','clearance') 1443 #wftool.doActionFor(student.clearance,'open') 1444 clearance = getattr(student,'clearance') 1445 dict = {'Title': 'Clearance/Eligibility Record'} 1446 clearance.getContent().edit(mapping = dict) 1447 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 1448 # 1449 # Study Course 1450 # 1451 student.invokeFactory('StudentStudyCourse','study_course') 1452 study_course = student.study_course 1453 dict = {} 1454 r2d = [('session','current_session'), 1455 ('level','current_level'), 1456 ('verdict','current_verdict'), 1457 ('study_course','study_course'), 1458 ] 1459 for r,d in r2d: 1460 dict[d] = record[r] 1461 study_course.getContent().edit(mapping=dict) 1462 # 1463 # Study Level 1464 # 1465 level = record['level'] 1466 study_course.invokeFactory('StudentStudyLevel',level) 1467 study_level = getattr(study_course,level) 1468 dict = {} 1469 r2d = [('session','session'), 1470 ('level','code'), 1471 ('verdict','verdict'), 1472 ] 1473 for r,d in r2d: 1474 dict[d] = record[r] 1475 study_level.getContent().edit(mapping=dict) 1476 wftool.doActionFor(student,'return') 1477 imported.append(format % record) 1478 tr_count += 1 1479 record['tr_count'] = tr_count 1480 record['total'] = total 1481 logger.info('%(total)s+%(tr_count)s: Creating Student %(student_id)s %(matric_no)s %(jamb_reg_no)s' % record) 1482 if tr_count > 1000: 1483 if len(not_imported) > 0: 1484 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 1485 '\n'.join(not_imported)+'\n') 1486 not_imported = [] 1487 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 1488 '\n'.join(imported) + '\n') 1489 imported = [] 1490 em = '%d transactions commited total %s' % (tr_count,total) 1491 transaction.commit() 1492 logger.info(em) 1493 regs = [] 1494 total += tr_count 1495 tr_count = 0 1496 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 1497 '\n'.join(imported)) 1498 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 1499 '\n'.join(not_imported)) 1500 em = '%d transactions commited total %d' % (tr_count,total) 1127 1501 logger.info(em) 1128 1502 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) … … 1241 1615 ###) 1242 1616 1243 def generateStudentId(self,letter ): ###(1617 def generateStudentId(self,letter,students = None): ###( 1244 1618 import random 1245 1619 r = random 1620 if students is None: 1621 students = self.portal_url.getPortalObject().campus.students 1246 1622 if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'): 1247 1623 letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY') 1248 students = self.portal_catalog(meta_type = "StudentsFolder")[-1]1249 1624 sid = "%c%d" % (letter,r.randint(99999,1000000)) 1250 1625 while hasattr(students, sid): … … 1263 1638 1264 1639 ###) 1265 1266 1640 1267 1641 class Student(CPSDocument): ###( … … 1429 1803 return "Level %s" % self.aq_parent.getId() 1430 1804 1431 def create_course_results(self,cert_id,current_level): 1805 def create_course_results(self,cert_id,current_level): ###( 1432 1806 "create all courses in a level" 1433 1807 aq_portal = self.portal_catalog.evalAdvancedQuery … … 1451 1825 course_result.getContent().edit(mapping=d) 1452 1826 transaction.commit() 1827 ###) 1453 1828 1454 1829 InitializeClass(StudentStudyLevel) -
WAeUP_SRP/trunk/WAeUPTables.py
r1625 r1700 25 25 from AccessControl import ClassSecurityInfo 26 26 from Products.CMFCore.permissions import ModifyPortalContent 27 27 import urllib 28 28 import DateTime,time 29 29 import csv,re … … 77 77 78 78 def deleteRecord(self, uid): 79 #import pdb;pdb.set_trace()80 79 self.uncatalog_object(uid) 81 80 … … 230 229 name = "students_catalog" 231 230 key = "id" 232 interesting_types = ('Student', 233 'StudentApplication', 234 'StudentCLearance', 235 'StudentPersonal', 236 'StudentStudyCourse', 237 ) 231 affected_types = { ###( 232 'StudentApplication': 233 ('jamb_reg_no', 234 'entry_mode', 235 'entry_session', 236 ), 237 'StudentClearance': 238 ('matric_no', 239 ), 240 'StudentPersonal': 241 ('name', 242 'sex', 243 'email', 244 'phone', 245 ), 246 'StudentStudyCourse': 247 ('course', 248 'faculty', 249 'department', 250 'level', 251 'study_mode', 252 'session', 253 'verdict', 254 ), 255 } 256 ###) 238 257 239 258 def __init__(self): … … 241 260 return 242 261 243 def get_review_state(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): ###( 244 "return the students review_state from portal_catalog" 245 cat_res = self.portal_catalog(id = sid) 246 if len(cat_res) != 1: 247 return None 248 return cat_res[0].review_state 249 250 def get_course(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 251 "return the students study_course" 252 if study_course_doc is None: 253 return None 254 return getattr(study_course_doc,'study_course',None) 255 256 def get_department(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 257 "return the students department" 258 if study_course_doc is None: 259 return None 260 certificate_res = self.portal_catalog(id = study_course_doc.study_course) 261 if len(certificate_res) != 1: 262 return None 263 return certificate_res[0].getPath().split('/')[-3] 264 265 def get_email(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 266 "return the students email from the personal" 267 if personal_doc is None: 268 return None 269 return getattr(personal_doc,'email',None) 270 271 def get_entry_mode(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 272 "return the students entry_mode from the application" 273 if application_doc is None: 274 return None 275 return getattr(application_doc,'entry_mode',None) 276 277 def get_jamb_reg_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 278 "return the students jamb_reg_no from the application" 279 if application_doc is None: 280 return None 281 return getattr(application_doc,'jamb_reg_no',None) 282 283 def get_faculty(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 284 "return the students faculty" 285 if study_course_doc is None: 286 return None 287 certificate_res = self.portal_catalog(id = study_course_doc.study_course) 288 if len(certificate_res) != 1: 289 return None 290 return certificate_res[0].getPath().split('/')[-4] 291 292 def get_level(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 293 "return the students study_course" 294 if study_course_doc is None: 295 return None 296 #from pdb import set_trace;set_trace() 297 return getattr(study_course_doc,'current_level',None) 298 299 def get_matric_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 300 "return the students matric_no from the clearance " 301 if clearance_doc is None: 302 return None 303 return getattr(clearance_doc,'matric_no',None) 304 305 def get_name(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 306 "return the students name from the personal" 307 if personal_doc is None: 308 return None 309 doc = personal_doc 310 return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname) 311 312 def get_phone(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 313 "return the students phone from the personal" 314 if personal_doc is None: 315 return None 316 return getattr(personal_doc,'phone',None) 317 318 def get_sex(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 319 "return the students sex from the personal" 320 if personal_doc is None: 321 return None 322 return getattr(personal_doc,'sex',None) 323 324 def get_verdict(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): 325 "return the students study_course" 326 if study_course_doc is None: 327 return None 328 return getattr(study_course_doc,'current_verdict',None) 329 ###) 330 331 def refreshCatalog(self, clear=0, pghandler=None): ###( 332 """ re-index everything we can find """ 333 students_folder = self.portal_url.getPortalObject().campus.students 334 335 cat = self._catalog 336 paths = self._catalog.uids.items() 337 if clear: 338 paths = tuple(paths) 339 cat.clear() 340 341 num_objects = len(paths) 342 if pghandler: 343 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 344 for i in xrange(num_objects): 345 if pghandler: pghandler.report(i) 346 p = paths[i] 347 sid = p[0] 348 pcat_res = self.portal_catalog(id=sid) 349 if len(pcat_res) != 1: 350 continue 351 student_brain = pcat_res[0] 352 student_obj = student_brain.getObject() 353 if student_obj.hasObject('application'): 354 application_doc = getattr(student_obj,'application').getContent() 355 else: 356 application_doc = None 357 if student_obj.hasObject('clearance'): 358 clearance_doc = getattr(student_obj,'clearance').getContent() 359 else: 360 clearance_doc = None 361 if student_obj.hasObject('personal'): 362 personal_doc = getattr(student_obj,'personal').getContent() 363 else: 364 personal_doc = None 365 if student_obj.hasObject('study_course'): 366 study_course_doc = getattr(student_obj,'study_course').getContent() 367 else: 368 study_course_doc = None 369 data = {} 370 data['id'] = sid 371 for field in self.schema(): 372 function = getattr(self,"get_%s" % field, None) 373 if function is None: 374 continue 375 value = function(sid,application_doc,clearance_doc,personal_doc,study_course_doc) 376 if value is not None: 377 data[field] = value 378 self.modifyRecord(**data) 379 if pghandler: pghandler.finish() 380 ###) 381 382 def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): 262 def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None): 263 """ clears the whole enchilada """ 264 self._catalog.clear() 265 266 if REQUEST and RESPONSE: 267 RESPONSE.redirect( 268 URL1 + 269 '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Cleared') 270 271 def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): ###( 383 272 """ clear the catalog, then re-index everything """ 384 273 … … 388 277 pgthreshold = self._getProgressThreshold() 389 278 handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None 390 self.refreshCatalog(clear= 0, pghandler=handler)279 self.refreshCatalog(clear=1, pghandler=handler) 391 280 392 281 elapse = time.time() - elapse … … 399 288 'Total time: %s\n' 400 289 'Total CPU time: %s' % (`elapse`, `c_elapse`))) 401 402 403 security.declarePrivate('notify_event_listener') 290 ###) 291 292 def get_from_doc_department(self,doc): ###( 293 "return the students department" 294 if doc is None: 295 return None 296 certificate_res = self.portal_catalog(id = doc.study_course) 297 if len(certificate_res) != 1: 298 return None 299 return certificate_res[0].getPath().split('/')[-3] 300 301 def get_from_doc_faculty(self,doc): 302 "return the students faculty" 303 if doc is None: 304 return None 305 certificate_res = self.portal_catalog(id = doc.study_course) 306 if len(certificate_res) != 1: 307 return None 308 return certificate_res[0].getPath().split('/')[-4] 309 310 def get_from_doc_level(self,doc): 311 "return the students level" 312 if doc is None: 313 return None 314 return getattr(doc,'current_level',None) 315 316 def get_from_doc_study_mode(self,doc): 317 "return the students study_mode" 318 if doc is None: 319 return None 320 return getattr(doc,'current_study_mode',None) 321 322 def get_from_doc_entry_session(self,doc): 323 "return the students entry_session" 324 if doc is None: 325 return None 326 try: 327 digit = int(doc.jamb_reg_no[0]) 328 except: 329 return "xx" 330 if digit < 8: 331 return "0%c" % doc.jamb_reg_no[0] 332 return "9%c" % doc.jamb_reg_no[0] 333 334 def get_from_doc_session(self,doc): 335 "return the students session" 336 if doc is None: 337 return None 338 return getattr(doc,'current_session',None) 339 340 def get_from_doc_course(self,doc): 341 "return the students study_course" 342 if doc is None: 343 return None 344 return getattr(doc,'study_course',None) 345 346 def get_from_doc_name(self,doc): 347 "return the students name from the personal" 348 if doc is None: 349 return None 350 return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname) 351 352 def get_from_doc_verdict(self,doc): 353 "return the students study_course" 354 if doc is None: 355 return None 356 return getattr(doc,'current_verdict',None) 357 358 ###) 359 360 def refreshCatalog(self, clear=0, pghandler=None): ###( 361 """ re-index everything we can find """ 362 students_folder = self.portal_url.getPortalObject().campus.students 363 364 cat = self._catalog 365 paths = self._catalog.uids.items() 366 if clear: 367 paths = tuple(paths) 368 cat.clear() 369 students = self.portal_catalog(portal_type="Student") 370 num_objects = len(students) 371 if pghandler: 372 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 373 for i in xrange(num_objects): 374 if pghandler: pghandler.report(i) 375 student_brain = students[i] 376 spath = student_brain.getPath() 377 student_obj = student_brain.getObject() 378 data = {} 379 sid = data['id'] = student_brain.getId 380 data['review_state'] = student_brain.review_state 381 sub_brains = self.portal_catalog(path = spath) 382 if len(sub_brains) > 1: 383 for sub_brain in sub_brains: 384 if not sub_brain.portal_type in self.affected_types.keys(): 385 continue 386 doc = sub_brain.getObject().getContent() 387 for field in self.affected_types[sub_brain.portal_type]: 388 if hasattr(self,'get_from_doc_%s' % field): 389 data[field] = getattr(self,'get_from_doc_%s' % field)(doc) 390 else: 391 data[field] = getattr(doc,field) 392 elif len(sub_brains) == 1: 393 #import pdb;pdb.set_trace() 394 import_res = self.returning_import(id = sid) 395 if not import_res: 396 continue 397 import_record = import_res[0] 398 data['matric_no'] = import_record.matric_no 399 data['sex'] = import_record.Sex == 'F' 400 data['name'] = "%s %s %s" % (import_record.Firstname, 401 import_record.Middlename, 402 import_record.Lastname) 403 data['matric_no'] = import_record.Entryregno 404 study_course = getattr(student_obj,'study_course',None) 405 current_level = data.get('level',None) 406 data['registered_courses'] = [] 407 if study_course and current_level and current_level in study_course.objectIds(): 408 level_obj = getattr(study_course,current_level) 409 courses = [] 410 for c in level_obj.objectIds(): 411 if c.endswith('_co'): 412 courses.append(c[:-3]) 413 else: 414 courses.append(c) 415 data['registered_courses'] = courses 416 self.addRecord(**data) 417 if pghandler: pghandler.finish() 418 ###) 419 420 421 security.declarePrivate('notify_event_listener') ###( 404 422 def notify_event_listener(self,event_type,object,infos): 405 423 "listen for events" … … 407 425 mt = object.meta_type 408 426 students_catalog = self.students_catalog 409 #if pt not in self.interesting_types: 410 # return 411 #print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars() 427 if pt not in self.affected_types.keys(): 428 return 412 429 if not infos.has_key('rpath'): 413 430 return 414 if pt == 'Student' and event_type == "workflow": 415 pass 416 elif mt == 'StudentApplication': 417 if event_type not in ('sys_modify_object'): 418 return 419 print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars() 431 rpl = infos['rpath'].split('/') 432 if pt == 'Student' and event_type == "sys_add_object": 433 student_id = object.id 434 try: 435 self.addRecord(id = student_id) 436 except ValueError: 437 pass 438 return 439 elif pt == 'CourseResult' and mt == 'CPS Proxy Folder': 420 440 from pdb import set_trace;set_trace() 421 jamb_reg_no = getattr(object,'jamb_reg_no',None) 422 if jamb_reg_no is None: 423 return 424 student_id = infos['rpath'].split('/')[2] 425 self.fixName(student_id) 426 student_entry = students_catalog(id = student_id)[0] 427 if student_entry.jamb_reg_no == jamb_reg_no: 428 return 429 students_catalog.modifyRecord(id = student_id, 430 jamb_reg_no = jamb_reg_no) 431 elif mt == 'StudentPersonal': 432 if event_type not in ('sys_modify_object'): 433 return 434 print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars() 435 student_id = infos['rpath'].split('/')[2] 436 self.fixName(student_id) 441 442 if event_type not in ('sys_modify_object'): 443 return 444 data = {} 445 if mt == 'CPS Proxy Folder': 446 return 447 #from pdb import set_trace;set_trace() 448 for field in self.affected_types[pt]: 449 if hasattr(self,'get_from_doc_%s' % field): 450 data[field] = getattr(self,'get_from_doc_%s' % field)(object) 451 else: 452 data[field] = getattr(object,field) 453 data['id'] = rpl[2] 454 students_catalog.modifyRecord(**data) 455 ###) 437 456 438 457 -
WAeUP_SRP/trunk/WAeUPTool.py
r1695 r1700 531 531 ###) 532 532 533 security.declareProtected(ModifyPortalContent,"get InvalidCallbackTransactions")###(533 security.declareProtected(ModifyPortalContent,"getCallbacksFromLog")###( 534 534 def getCallbacksFromLog(self,filename): 535 535 """fix Online Payment Transactions from Z2.log entries""" -
WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml
r1415 r1700 154 154 <property name="hidden_readonly_layout_modes"/> 155 155 </widget> 156 <widget name="jamb_reg_no" meta_type=" JambRegNoWidget">156 <widget name="jamb_reg_no" meta_type="String Widget"> 157 157 <property name="title">JAMB Registration Number</property> 158 158 <property name="fields"> -
WAeUP_SRP/trunk/profiles/default/returning_import.xml
r1556 r1700 2 2 <?xml-stylesheet type="text/xsl" href="catalog.xsl"?> 3 3 <object name="returning_import" meta_type="WAeUP Table"> 4 <column value="id"/> 4 5 <column value="matric_no"/> 5 6 <column value="Entryregno"/> … … 25 26 <indexed_attr value="matric_no"/> 26 27 </index> 28 <index name="id" meta_type="FieldIndex"> 29 <indexed_attr value="id"/> 30 </index> 27 31 </object> -
WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml
r1544 r1700 1 1 <?xml version="1.0"?> 2 2 <?xml-stylesheet type="text/xsl" href="schema.xsl"?> 3 <object name=" student_application" meta_type="CPS Schema">3 <object name="import_student" meta_type="CPS Schema"> 4 4 <field name="mode" meta_type="CPS String Field"/> 5 <field name="fullname" meta_type="CPS String Field"/> 5 <field name="firstname" meta_type="CPS String Field"/> 6 <field name="middlename" meta_type="CPS String Field"/> 7 <field name="lastname" meta_type="CPS String Field"/> 6 8 <field name="sex" meta_type="CPS String Field"/> 7 9 <field name="jamb_reg_no" meta_type="CPS String Field"/> 8 10 <field name="entry_mode" meta_type="CPS String Field"/> 11 <field name="jamb_score" meta_type="CPS Int Field"/> 12 <field name="pume_score" meta_type="CPS Int Field"/> 9 13 <field name="faculty" meta_type="CPS String Field"/> 10 14 <field name="department" meta_type="CPS String Field"/> 11 15 <field name="study_course" meta_type="CPS String Field"/> 16 <field name="matric_no" meta_type="CPS String Field"/> 12 17 <field name="state" meta_type="CPS String Field"/> 13 18 <field name="lga" meta_type="CPS String Field"/> 14 <field name=" level" meta_type="CPS String Field"/>15 <field name=" verdict" meta_type="CPS String Field"/>19 <field name="phone" meta_type="CPS String Field"/> 20 <field name="email" meta_type="CPS String Field"/> 16 21 <field name="address" meta_type="CPS String Field"/> 17 22 </object> -
WAeUP_SRP/trunk/profiles/default/schemas/import_student_level_data.xml
r1533 r1700 3 3 <object name="import_student_level_data" meta_type="CPS Schema"> 4 4 <field name="matric_no" meta_type="CPS String Field"/> 5 <field name="session" meta_type="CPS String Field"/> 5 6 <field name="level" meta_type="CPS String Field"/> 6 7 <field name="verdict" meta_type="CPS String Field"/> 7 8 </object> 8 -
WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml
r1399 r1700 9 9 <field name="objection_date" meta_type="CPS DateTime Field"/> 10 10 <field name="jamb_age" meta_type="CPS Int Field"/> 11 <field name="import_mode" meta_type="CPS String Field"/> 11 12 <field name="jamb_first_cos" meta_type="CPS String Field"/> 12 13 <field name="jamb_first_uni" meta_type="CPS String Field"/> -
WAeUP_SRP/trunk/profiles/default/schemas/student_course_result.xml
r1520 r1700 4 4 <field name="code" meta_type="CPS String Field"/> 5 5 <field name="title" meta_type="CPS String Field"/> 6 <field name="faculty_code" meta_type="CPS String Field"/>7 <field name="department_code" meta_type="CPS String Field"/>8 6 <field name="credits" meta_type="CPS Int Field"/> 9 7 <field name="core_or_elective" meta_type="CPS Boolean Field"/> 10 <field name="passmark" meta_type="CPS Int Field"/>11 <field name="ansbook" meta_type="CPS String Field"/>12 8 <field name="carry_level" meta_type="CPS String Field"/> 13 9 <field name="grade" meta_type="CPS String Field"/> 14 <field name="import_id" meta_type="CPS String Field"/>15 10 <field name="score" meta_type="CPS Int Field"/> 16 11 <field name="status" meta_type="CPS String Field"/> -
WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml
r1401 r1700 6 6 <property name="is_searchabletext">True</property> 7 7 </field> 8 <field name="current_session" meta_type="CPS String Field"/> 9 <field name="current_study_mode" meta_type="CPS String Field"/> 8 10 <field name="current_level" meta_type="CPS String Field"/> 9 11 <field name="current_verdict" meta_type="CPS String Field"/> -
WAeUP_SRP/trunk/profiles/default/students_catalog.xml
r1626 r1700 2 2 <?xml-stylesheet type="text/xsl" href="catalog.xsl"?> 3 3 <object name="students_catalog" meta_type="WAeUP Table"> 4 <object name="plaintext_lexicon" meta_type="ZCTextIndex Lexicon"> 5 <element name="Whitespace splitter" group="Word Splitter"/> 6 <element name="Case Normalizer" group="Case Normalizer"/> 7 <element name="Remove listed stop words only" group="Stop Words"/> 8 </object> 9 <index name="id" meta_type="FieldIndex"> 10 <indexed_attr value="id"/> 11 </index> 12 <index name="review_state" meta_type="FieldIndex"> 13 <indexed_attr value="review_state"/> 14 </index> 15 <index name="name" meta_type="TextIndex"> 16 <indexed_attr value="name"/> 17 </index> 18 <index name="jamb_reg_no" meta_type="FieldIndex"> 19 <indexed_attr value="jamb_reg_no"/> 20 </index> 21 <index name="matric_no" meta_type="FieldIndex"> 22 <indexed_attr value="matric_no"/> 23 </index> 24 <index name="faculty" meta_type="FieldIndex"> 25 <indexed_attr value="faculty"/> 26 </index> 27 <index name="entry_mode" meta_type="FieldIndex"> 28 <indexed_attr value="entry_mode"/> 29 </index> 30 <index name="entry_session" meta_type="FieldIndex"> 31 <indexed_attr value="entry_session"/> 32 </index> 33 <index name="department" meta_type="FieldIndex"> 34 <indexed_attr value="department"/> 35 </index> 36 <index name="level" meta_type="FieldIndex"> 37 <indexed_attr value="level"/> 38 </index> 39 <index name="study_mode" meta_type="FieldIndex"> 40 <indexed_attr value="study_mode"/> 41 </index> 42 <index name="verdict" meta_type="FieldIndex"> 43 <indexed_attr value="verdict"/> 44 </index> 45 <index name="course" meta_type="FieldIndex"> 46 <indexed_attr value="course"/> 47 </index> 48 <index name="registered_courses" meta_type="KeywordIndex"> 49 <indexed_attr value="registered_courses"/> 50 </index> 4 51 <column value="id"/> 52 <column value="review_state"/> 5 53 <column value="matric_no"/> 6 54 <column value="jamb_reg_no"/> … … 10 58 <column value="department"/> 11 59 <column value="course"/> 60 <column value="registered_courses"/> 12 61 <column value="email"/> 13 62 <column value="phone"/> 14 63 <column value="level"/> 64 <column value="study_mode"/> 15 65 <column value="verdict"/> 16 66 <column value="entry_mode"/> 17 <index name="id" meta_type="FieldIndex"> 18 <indexed_attr value="id"/> 19 </index> 20 <index name="jamb_reg_no" meta_type="FieldIndex"> 21 <indexed_attr value="jamb_reg_no"/> 22 </index> 23 <index name="matric_no" meta_type="FieldIndex"> 24 <indexed_attr value="matric_no"/> 25 </index> 26 <index name="faculty" meta_type="KeywordIndex"> 27 <indexed_attr value="faculty"/> 28 </index> 29 <index name="entry_mode" meta_type="KeywordIndex"> 30 <indexed_attr value="entry_mode"/> 31 </index> 32 <index name="department" meta_type="KeywordIndex"> 33 <indexed_attr value="department"/> 34 </index> 35 <index name="level" meta_type="KeywordIndex"> 36 <indexed_attr value="current_level"/> 37 </index> 38 <index name="verdict" meta_type="KeywordIndex"> 39 <indexed_attr value="current_verdict"/> 40 </index> 41 <index name="course" meta_type="KeywordIndex"> 42 <indexed_attr value="study_course"/> 43 </index> 67 <column value="entry_session"/> 44 68 </object> -
WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py
r1490 r1700 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= 7 ##parameters=student_id=None 8 8 ##title= 9 9 ## … … 17 17 except: 18 18 aq_portal = None 19 student_id = context.getStudentId() 19 if student_id is None: 20 student_id = context.getStudentId() 20 21 query = Eq('id',student_id) 21 22 res = aq_portal(query) -
WAeUP_SRP/trunk/skins/waeup_student/list_students.py
r1668 r1700 49 49 newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*') 50 50 #newquery = MatchRegexp('SearchableText','^5*') 51 new_students = aq_portal(newquery) 52 new_sids = [] 53 for ns in new_students: 54 new_sids.append(ns.getPath().split('/')[-2]) 51 #new_students = aq_portal(newquery) 52 #set_trace() 53 #new_sids = [] 54 #for ns in new_students: 55 # new_sids.append(ns.getPath().split('/')[-2]) 56 #set_trace() 55 57 for student in cleared: 56 if student.getId not in new_sids:57 continue58 ## if student.getId not in new_sids: 59 ## continue 58 60 erg = scat(id=student.getId) 59 61 if not erg: 62 continue 63 if not erg[0].jamb_reg_no.startswith('6'): 60 64 continue 61 65 d = context.getFormattedStudentEntry(erg[0]) -
WAeUP_SRP/trunk/skins/waeup_utilities/readOnlinePaymentsFromLog.py
r1667 r1700 95 95 )) 96 96 if payment_doc.resp_code == "" and response_code == "00": 97 pd = {}98 97 review_state = wftool.getInfoFor(payment_obj,'review_state',None) 99 98 if review_state != "opened": … … 104 103 logger.info('%s review_state = %s' % (student_id,review_state)) 105 104 continue 106 pd['resp_code'] = 'IP' 107 pd['resp_desc'] = 'Payment approved by import, %s' % (DateTime.DateTime()) 108 payment_doc.edit(mapping=pd) 105 readin['resp_code'] = 'IP ' + readin['resp_code'] 106 readin['resp_desc'] = 'Payment approved by logfile import, %s. ' % (DateTime.DateTime()) \ 107 + readin['resp_desc'] 108 payment_doc.edit(mapping=readin) 109 109 if payment_doc.type_description.startswith('School Fee'): 110 110 wftool.doActionFor(student_obj,'pay_school_fee') 111 logger.info('%s approves epayment for %s by import' % (member,student_id))111 logger.info('%s approves epayment for %s by logfile import' % (member,student_id)) 112 112 wftool.doActionFor(payment_obj,'close') 113 113 approved += 1
Note: See TracChangeset for help on using the changeset viewer.