Changeset 16819
- Timestamp:
- 21 Feb 2022, 09:39:05 (3 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16818 r16819 4 4 1.7.2.dev0 (unreleased) 5 5 ======================= 6 7 * Enable import of student history. 6 8 7 9 * Don't complain but remove leading and trailing whitespaces -
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r16079 r16819 27 27 import unicodecsv as csv # XXX: csv ops should move to dedicated module. 28 28 from time import time 29 from ast import literal_eval 29 30 from datetime import datetime 30 31 from zope.i18n import translate … … 92 93 return sorted(list(set( 93 94 ['student_id','reg_number','matric_number', 94 'password', 'state', 'transition' ] + fields.keys())))95 'password', 'state', 'transition', 'history'] + fields.keys()))) 95 96 96 97 def checkHeaders(self, headerfields, mode='create'): … … 227 228 row.pop('password') 228 229 230 # Replace entire history 231 if 'history' in row: 232 new_history = row.get('history', IGNORE_MARKER) 233 if new_history not in (IGNORE_MARKER, ''): 234 history = IObjectHistory(obj) 235 history._annotations[ 236 history.history_key] = literal_eval(new_history) 237 items_changed += ('%s=%s, ' % ('history', new_history)) 238 row.pop('history') 239 229 240 # Update registration state 230 241 if 'state' in row: … … 233 244 value = row['state'] 234 245 IWorkflowState(obj).setState(value) 235 msg = _("State '${a}' set", mapping = {'a':value})246 msg = _("State '${a}' imported", mapping = {'a':value}) 236 247 history = IObjectHistory(obj) 237 248 history.addMessage(msg) … … 302 313 row['state'] not in (IGNORE_MARKER, ''): 303 314 errs.append(('workflow','not allowed')) 304 return errs, inv_errs, conv_dict305 315 if 'transition' in row: 306 316 if row['transition'] not in IMPORTABLE_TRANSITIONS: … … 315 325 # be changed if empty. 316 326 conv_dict['state'] = IGNORE_MARKER 327 if 'history' in row: 328 if row['history'] not in (IGNORE_MARKER, ''): 329 try: 330 new_history = literal_eval(row['history']) 331 except: 332 errs.append(('history','malformed string')) 317 333 try: 318 334 # Correct stud_id counter. As the IConverter for students -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv
r15628 r16819 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex,state,password 2 X666666,Aaren,Pieri,1,1990-01-02,100000,,1234,M,courses validated,test1234 3 Y777777,Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,m,courses validated, 4 ,Susann,Berson,3,1990-01-04,100002,aa@aa.ng,1234,F,courses validated, 5 ,Else,Mueller,4,1990-01-05,100003,aa@aa.ng,1234,f,school fee paid, 6 ,,,,,,,,,, 7 ,,,, ,,, ,,, 8 ,,,,<IGNORE>,,,<IGNORE>,,, 9 X888888,Alfons,Meier,5,1990-01-02,100004,aa@aa.ng,1234,m,courses validated, 10 X999999,Herbert,Mueller,6,1990-01-02,100005,aa@aa.ng,1234,m,courses registered, 11 X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated, 12 X222222,Thomas,Kinderman,8,1990-01-02,100007,aa@aa.ng,1234,m,courses validated, 13 X333333,Paula,Schall,9,1990-01-02,100008,aa@aa.ng,1234,m,courses registered, 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex,state,password,history 2 X666666,Aaren,Pieri,1,1990-01-02,100000,,1234,M,courses validated,test1234,"[u'2012-10-23 00:05:39 WAT - Record created by System Admin', u'2012-10-23 00:05:39 WAT - Admitted by System Admin',u""2021-02-21 12:49:12 WAT - State 'graduated' set by System Admin""]" 3 Y777777,Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,m,courses validated,, 4 ,Susann,Berson,3,1990-01-04,100002,aa@aa.ng,1234,F,courses validated,, 5 ,Else,Mueller,4,1990-01-05,100003,aa@aa.ng,1234,f,school fee paid,, 6 ,,,,,,,,,,, 7 ,,,, ,,, ,,,, 8 ,,,,<IGNORE>,,,<IGNORE>,,,, 9 X888888,Alfons,Meier,5,1990-01-02,100004,aa@aa.ng,1234,m,courses validated,, 10 X999999,Herbert,Mueller,6,1990-01-02,100005,aa@aa.ng,1234,m,courses registered,, 11 X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated,, 12 X222222,Thomas,Kinderman,8,1990-01-02,100007,aa@aa.ng,1234,m,courses validated,, 13 X333333,Paula,Schall,9,1990-01-02,100008,aa@aa.ng,1234,m,courses registered,, -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_migration.csv
r8355 r16819 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password,sex,state 2 A123456,Aaren,Pieri,1,1990-01-02#,100000,aa@aa.ng,1234,mypw1,m,clearance started 3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1,m,cleared 4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,{SSHA}JJBeA47pgGah500NFpuM2tVeLAbM8dxj,m,admitted 5 D123456,John,Wolter,4,1990-01-05,100003,aa@aa.ng,1234,mypw1,m,nonsense 6 E123456,John,Kennedy,5,1990-01-06,100004,aa@aa.ng,1234,,x, 7 F123456,Frank,Meyer,6,1990-01-06,100005,aa@aa.ng,1234,,m, 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password,sex,state,history 2 A123456,Aaren,Pieri,1,1990-01-02#,100000,aa@aa.ng,1234,mypw1,m,clearance started,"[u'2012-10-23 00:05:39 WAT - Record created by System Admin', u'2012-10-23 00:05:39 WAT - Admitted by System Admin',u""2021-02-21 12:49:12 WAT - State 'graduated' set by System Admin""]" 3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1,m,cleared, 4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,{SSHA}JJBeA47pgGah500NFpuM2tVeLAbM8dxj,m,admitted, 5 D123456,John,Wolter,4,1990-01-05,100003,aa@aa.ng,1234,mypw1,m,nonsense, 6 E123456,John,Kennedy,5,1990-01-06,100004,aa@aa.ng,1234,,x,, 7 F123456,Frank,Meyer,6,1990-01-06,100005,aa@aa.ng,1234,,m,, 8 G123456,Ulli,Meyer,7,1990-01-06,100007,aa@aa.ng,1234,,m,,nonsense -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r16812 r16819 420 420 self.assertEqual( 421 421 self.app['students']['X666666'].state, 'courses validated') 422 # history was successfully impotrted 423 history = self.app['students']['X666666'].history.messages 424 self.assertEqual(history[0], 425 '2012-10-23 00:05:39 WAT - Record created by System Admin') 426 self.assertTrue( 427 "State 'courses validated' imported by system" in history[3]) 428 # history import has been logged 429 logcontent = open(self.logfile).read() 430 self.assertTrue( 431 "history=[u'2012-10-23 00:05:39 WAT - Record created by System Admin'" 432 in logcontent) 422 433 # Two new student_ids have been created. 423 434 self.assertEqual(self.app['students']._curr_stud_id, 1000003) … … 514 525 self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION) 515 526 content = open(fail_file).read() 516 self.assertEqual(num_warns, 2)527 self.assertEqual(num_warns,3) 517 528 assert len(self.app['students'].keys()) == 5 518 529 self.assertEqual( 519 530 content, 520 'reg_number,firstname,student_id,sex,email,phone,state,date_of_birth,lastname,password,matric_number,--ERRORS--\r\n' 521 '4,John,D123456,m,aa@aa.ng,1234,nonsense,1990-01-05,Wolter,mypw1,100003,state: not allowed\r\n' 522 '5,John,E123456,x,aa@aa.ng,1234,<IGNORE>,1990-01-06,Kennedy,<IGNORE>,100004,sex: Invalid value\r\n' 531 'reg_number,firstname,student_id,sex,email,phone,state,date_of_birth,lastname,password,matric_number,history,--ERRORS--\r\n' 532 '4,John,D123456,m,aa@aa.ng,1234,nonsense,1990-01-05,Wolter,mypw1,100003,<IGNORE>,state: not allowed\r\n' 533 '5,John,E123456,x,aa@aa.ng,1234,<IGNORE>,1990-01-06,Kennedy,<IGNORE>,100004,<IGNORE>,sex: Invalid value\r\n' 534 '7,Ulli,G123456,m,aa@aa.ng,1234,<IGNORE>,1990-01-06,Meyer,<IGNORE>,100007,nonsense,history: malformed string\r\n' 523 535 ) 524 536 students = self.app['students'] … … 532 544 datetime.date(1990, 1, 3)) 533 545 self.assertTrue(students['B123456'].clearance_locked) 534 history = ' '.join(students['A123456'].history.messages) 546 history = students['A123456'].history.messages 547 self.assertEqual(history[0], 548 '2012-10-23 00:05:39 WAT - Record created by System Admin') 535 549 self.assertTrue( 536 "State 'clearance started' set by system" in history)550 "State 'clearance started' imported by system" in history[3]) 537 551 # state was empty and student is thus in state created 538 552 self.assertEqual(students['F123456'].state,'created') … … 723 737 self.assertEqual(self.student.current_mode, 'ug_pt') 724 738 shutil.rmtree(os.path.dirname(fin_file)) 725 # Trans er has bee logged.739 # Transfer has bee logged. 726 740 logcontent = open(self.logfile).read() 727 741 self.assertTrue(
Note: See TracChangeset for help on using the changeset viewer.