Changeset 8287


Ignore:
Timestamp:
26 Apr 2012, 14:13:51 (13 years ago)
Author:
Henrik Bettermann
Message:

Rename reg_state to state to be in accordance with applicants.

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

Legend:

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

    r8284 r8287  
    6464        return sorted(list(set(
    6565            ['student_id','reg_number','matric_number',
    66             'password', 'reg_state'] + getFields(
     66            'password', 'state'] + getFields(
    6767                self.iface).keys())))
    6868
     
    133133        parent = self.getParent(row, site)
    134134        parent.addStudent(obj)
    135         # We have to log this if reg_state is provided. If not,
     135        # We have to log this if state is provided. If not,
    136136        # logging is done by the event handler handle_student_added
    137         if row.has_key('reg_state'):
     137        if row.has_key('state'):
    138138            parent.logger.info('%s - Student record created' % obj.student_id)
    139139        history = IObjectHistory(obj)
     
    166166
    167167        # Update registration state
    168         reg_state = row.get('reg_state', IGNORE_MARKER)
    169         if reg_state not in (IGNORE_MARKER, ''):
    170             value = row['reg_state']
     168        state = row.get('state', IGNORE_MARKER)
     169        if state not in (IGNORE_MARKER, ''):
     170            value = row['state']
    171171            IWorkflowState(obj).setState(value)
    172172            msg = _("State '${a}' set", mapping = {'a':value})
    173173            history = IObjectHistory(obj)
    174174            history.addMessage(msg)
    175             row.pop('reg_state')
     175            row.pop('state')
    176176
    177177        # apply other values...
     
    219219        errs, inv_errs, conv_dict =  converter.fromStringDict(
    220220            row, self.factory_name, mode=mode)
    221         if row.has_key('reg_state') and \
    222             not row['reg_state'] in IMPORTABLE_STATES:
    223             if row['reg_state'] not in (IGNORE_MARKER, ''):
    224                 errs.append(('reg_state','not allowed'))
    225             #else:
    226             #    errs.append(('reg_state','no value provided'))
     221        if row.has_key('state') and \
     222            not row['state'] in IMPORTABLE_STATES:
     223            if row['state'] not in (IGNORE_MARKER, ''):
     224                errs.append(('state','not allowed'))
     225            else:
     226                # state is an attribute of Student and must not
     227                # be changed if empty
     228                conv_dict['state'] = IGNORE_MARKER
    227229        return errs, inv_errs, conv_dict
    228230
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r7949 r8287  
    156156    message.
    157157    """
    158     reg_state = IWorkflowState(student).getState()
    159     if reg_state == CLEARANCE:
     158    state = IWorkflowState(student).getState()
     159    if state == CLEARANCE:
    160160        student.clearance_locked = False
    161161    else:
     
    174174    role_manager.assignRoleToPrincipal(
    175175        'waeup.local.StudentRecordOwner', student.student_id)
    176     if reg_state is None:
     176    if state is None:
    177177        IWorkflowInfo(student).fireTransition('create')
    178178    return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv

    r8284 r8287  
    1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex,reg_state
     1student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,sex,state
    22X666666,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,m,courses validated
    33Y777777,Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,m,courses validated
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_migration.csv

    r8284 r8287  
    1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password,sex,reg_state
     1student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password,sex,state
    22A123456,Aaren,Pieri,1,1990-01-02#,100000,aa@aa.ng,1234,mypw1,m,clearance started
    33B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1,m,cleared
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_update.csv

    r8284 r8287  
    1 reg_number,date_of_birth,matric_number,reg_state
     1reg_number,date_of_birth,matric_number,state
    221,1980-01-02,10,admitted
    332,1980-01-03,11,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r8284 r8287  
    220220    def test_checkConversion(self):
    221221        errs, inv_errs, conv_dict = self.processor.checkConversion(
    222             dict(reg_number='1', reg_state='admitted'))
    223         self.assertEqual(len(errs),0)
    224         # Empty reg_state is allowed
    225         errs, inv_errs, conv_dict = self.processor.checkConversion(
    226             dict(reg_number='1', reg_state=''))
    227         self.assertEqual(len(errs),0)
    228         #self.assertTrue(('reg_state', 'no value provided') in errs)
    229         errs, inv_errs, conv_dict = self.processor.checkConversion(
    230             dict(reg_number='1', reg_state='nonsense'))
     222            dict(reg_number='1', state='admitted'))
     223        self.assertEqual(len(errs),0)
     224        # Empty state is allowed
     225        errs, inv_errs, conv_dict = self.processor.checkConversion(
     226            dict(reg_number='1', state=''))
     227        self.assertEqual(len(errs),0)
     228        #self.assertTrue(('state', 'no value provided') in errs)
     229        errs, inv_errs, conv_dict = self.processor.checkConversion(
     230            dict(reg_number='1', state='nonsense'))
    231231        self.assertEqual(len(errs),1)
    232         self.assertTrue(('reg_state', 'not allowed') in errs)
     232        self.assertTrue(('state', 'not allowed') in errs)
    233233
    234234    def test_delEntry(self):
     
    254254            self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'update')
    255255        self.assertEqual(num_warns,0)
    256         # reg_state has changed
     256        # state has changed
    257257        self.assertEqual(self.app['students']['X666666'].state,'admitted')
    258         # reg_state has not changed
     258        # state has not changed
    259259        self.assertEqual(self.app['students']['Y777777'].state,'courses validated')
    260260        shutil.rmtree(os.path.dirname(fin_file))
     
    301301        self.assertEqual(
    302302            content,
    303             'reg_number,firstname,student_id,sex,email,phone,date_of_birth,reg_state,lastname,password,matric_number,--ERRORS--\r\n'
    304             '4,John,D123456,m,aa@aa.ng,1234,1990-01-05,nonsense,Wolter,mypw1,100003,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'
     303            'reg_number,firstname,student_id,sex,email,phone,state,date_of_birth,lastname,password,matric_number,--ERRORS--\r\n'
     304            '4,John,D123456,m,aa@aa.ng,1234,nonsense,1990-01-05,Wolter,mypw1,100003,state: not allowed\r\n'
     305            '5,John,E123456,x,aa@aa.ng,1234,,1990-01-06,Kennedy,,100004,sex: Invalid value\r\n'
    306306            )
    307307        self.assertTrue('A123456' in self.app['students'].keys())
     
    317317        self.assertTrue(
    318318            "State 'clearance started' set by system" in history)
    319         # reg_state was empty and student is thus in state created
     319        # state was empty and student is thus in state created
    320320        self.assertEqual(self.app['students']['F123456'].state,'created')
    321321        shutil.rmtree(os.path.dirname(fin_file))
Note: See TracChangeset for help on using the changeset viewer.