Changeset 8284


Ignore:
Timestamp:
26 Apr 2012, 11:30:32 (13 years ago)
Author:
Henrik Bettermann
Message:

Allow empty reg_state cells. This is necessary particularly during mixed updates.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r8232 r8284  
    166166
    167167        # Update registration state
    168         if 'reg_state' in row.keys(): # and row['reg_state'] not in (IGNORE_MARKER, ''):
     168        reg_state = row.get('reg_state', IGNORE_MARKER)
     169        if reg_state not in (IGNORE_MARKER, ''):
    169170            value = row['reg_state']
    170171            IWorkflowState(obj).setState(value)
     
    220221        if row.has_key('reg_state') and \
    221222            not row['reg_state'] in IMPORTABLE_STATES:
    222             if row['reg_state'] != '':
     223            if row['reg_state'] not in (IGNORE_MARKER, ''):
    223224                errs.append(('reg_state','not allowed'))
    224             else:
    225                 errs.append(('reg_state','no value provided'))
     225            #else:
     226            #    errs.append(('reg_state','no value provided'))
    226227        return errs, inv_errs, conv_dict
    227228
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv

    r8210 r8284  
    11student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex,reg_state
    22X666666,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,m,courses validated
    3 ,Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,m,courses validated
     3Y777777,Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,m,courses validated
    44,Susann,Berson,3,1990-01-04,100002,aa@aa.ng,1234,f,courses validated
    55,Else,Mueller,4,1990-01-05,100003,aa@aa.ng,1234,f,courses registered
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_migration.csv

    r7983 r8284  
    44C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,mypw1,m,admitted
    55D123456,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
     6E123456,John,Kennedy,5,1990-01-06,100004,aa@aa.ng,1234,,x,
     7F123456,Frank,Meyer,5,1990-01-06,100004,aa@aa.ng,1234,,m,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_update.csv

    r6848 r8284  
    1 reg_number,date_of_birth,matric_number
    2 1,1980-01-02,10
    3 2,1980-01-03,11
    4 3,1980-01-04,12
     1reg_number,date_of_birth,matric_number,reg_state
     21,1980-01-02,10,admitted
     32,1980-01-03,11,
     43,1980-01-04,12,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r8231 r8284  
    222222            dict(reg_number='1', reg_state='admitted'))
    223223        self.assertEqual(len(errs),0)
     224        # Empty reg_state is allowed
    224225        errs, inv_errs, conv_dict = self.processor.checkConversion(
    225226            dict(reg_number='1', reg_state=''))
    226         self.assertEqual(len(errs),1)
    227         self.assertTrue(('reg_state', 'no value provided') in errs)
     227        self.assertEqual(len(errs),0)
     228        #self.assertTrue(('reg_state', 'no value provided') in errs)
    228229        errs, inv_errs, conv_dict = self.processor.checkConversion(
    229230            dict(reg_number='1', reg_state='nonsense'))
     
    243244        assert len(self.app['students'].keys()) == 5
    244245        self.assertEqual(self.app['students']['X666666'].reg_number,'1')
     246        self.assertEqual(self.app['students']['X666666'].state,'courses validated')
    245247        shutil.rmtree(os.path.dirname(fin_file))
    246248
     
    252254            self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'update')
    253255        self.assertEqual(num_warns,0)
     256        # reg_state has changed
     257        self.assertEqual(self.app['students']['X666666'].state,'admitted')
     258        # reg_state has not changed
     259        self.assertEqual(self.app['students']['Y777777'].state,'courses validated')
    254260        shutil.rmtree(os.path.dirname(fin_file))
    255261
     
    290296        num, num_warns, fin_file, fail_file = self.processor.doImport(
    291297            self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION)
     298        content = open(fail_file).read()
    292299        self.assertEqual(num_warns,2)
    293         assert len(self.app['students'].keys()) == 4
    294         content = open(fail_file).read()
     300        assert len(self.app['students'].keys()) == 5
    295301        self.assertEqual(
    296302            content,
    297303            'reg_number,firstname,student_id,sex,email,phone,date_of_birth,reg_state,lastname,password,matric_number,--ERRORS--\r\n'
    298304            '4,John,D123456,m,aa@aa.ng,1234,1990-01-05,nonsense,Wolter,mypw1,100003,reg_state: not allowed\r\n'
    299             '5,John,E123456,x,aa@aa.ng,1234,1990-01-06,,Kennedy,,100004,sex: Invalid value; reg_state: not allowed\r\n'
     305            '5,John,E123456,x,aa@aa.ng,1234,1990-01-06,,Kennedy,,100004,sex: Invalid value\r\n'
    300306            )
    301307        self.assertTrue('A123456' in self.app['students'].keys())
     
    311317        self.assertTrue(
    312318            "State 'clearance started' set by system" in history)
     319        # reg_state was empty and student is thus in state created
     320        self.assertEqual(self.app['students']['F123456'].state,'created')
    313321        shutil.rmtree(os.path.dirname(fin_file))
    314322
Note: See TracChangeset for help on using the changeset viewer.