Changeset 7513 for main/waeup.sirp


Ignore:
Timestamp:
25 Jan 2012, 17:47:23 (13 years ago)
Author:
Henrik Bettermann
Message:

Enable import of student registration states which are in IMPORTABLE_STATES.

Set workflow state directly rather than firing transitions.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
7 edited

Legend:

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

    r7497 r7513  
    3131from zope.event import notify
    3232from zope.catalog.interfaces import ICatalog
     33from hurry.workflow.interfaces import IWorkflowState
    3334from waeup.sirp.interfaces import (
    3435    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount)
     
    3637    IStudent, IStudentStudyCourseImport,
    3738    IStudentUpdateByRegNo, IStudentUpdateByMatricNo)
     39from waeup.sirp.students.workflow import  IMPORTABLE_STATES
    3840from waeup.sirp.utils.batching import BatchProcessor
    3941
     
    5860    def available_fields(self):
    5961        return sorted(list(set(
    60             ['student_id','reg_number','matric_number','password'] + getFields(
     62            ['student_id','reg_number','matric_number',
     63            'password', 'reg_state'] + getFields(
    6164                self.iface).keys())))
    6265
     
    144147            if key == 'password':
    145148                IUserAccount(obj).setPassword(value)
     149            elif key == 'reg_state':
     150                IWorkflowState(obj).setState(value)
    146151            elif hasattr(obj, key):
    147152                setattr(obj, key, value)
     
    177182        errs, inv_errs, conv_dict =  converter.fromStringDict(
    178183            row, self.factory_name)
     184        if row.has_key('reg_state') and \
     185            row['reg_state'] is not None and \
     186            not row['reg_state'] in IMPORTABLE_STATES:
     187            errs.append(('reg_state','not allowed'))
    179188        return errs, inv_errs, conv_dict
    180189
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7364 r7513  
    156156    role_manager.assignRoleToPrincipal(
    157157        'waeup.local.StudentRecordOwner', student.student_id)
    158     IWorkflowInfo(student).fireTransition('create')
     158    if IWorkflowState(student).getState() is None:
     159        IWorkflowInfo(student).fireTransition('create')
    159160    return
    160161
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/sample_student_data.csv

    r7357 r7513  
    1 firstname,lastname,reg_number,date_of_birth,matric_number,email,phone
     1firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,reg_state
    22Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234
    3 Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234
    4 Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234
     3Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,admitted
     4Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,cleared
     5John,Wolter,4,1990-01-04,100003,aa@aa.ng,1234,nonsense
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/sample_student_data_migration.csv

    r7497 r7513  
    1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password
    2 A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypw1
    3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1
    4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,mypw1
     1student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password,reg_state
     2A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypw1,school fee paid
     3B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1,cleared
     4C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,mypw1,admitted
     5D123456,John,Wolter,4,1990-01-04,100003,aa@aa.ng,1234,mypw1,nonsense
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py

    r7357 r7513  
    162162        num, num_warns, fin_file, fail_file = self.importer.doImport(
    163163            self.csv_file, STUDENT_HEADER_FIELDS)
    164         self.assertEqual(num_warns,0)
     164        self.assertEqual(num_warns,1)
    165165        assert len(self.app['students'].keys()) == 4
    166166        shutil.rmtree(os.path.dirname(fin_file))
     
    196196        num, num_warns, fin_file, fail_file = self.importer.doImport(
    197197            self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION)
    198         self.assertEqual(num_warns,0)
     198        self.assertEqual(num_warns,1)
    199199        assert len(self.app['students'].keys()) == 4
    200200        self.assertTrue('A123456' in self.app['students'].keys())
     201        self.assertEqual(self.app['students']['A123456'].state,'school fee paid')
    201202        shutil.rmtree(os.path.dirname(fin_file))
    202203
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7497 r7513  
    3131from zope.securitypolicy.interfaces import IPrincipalRoleManager
    3232from zope.testbrowser.testing import Browser
    33 from hurry.workflow.interfaces import IWorkflowInfo
     33from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3434from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    3535from waeup.sirp.app import University
     
    769769        prmlocal = IPrincipalRoleManager(department)
    770770        prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear')
    771         IWorkflowInfo(self.student).fireTransition('admit')
    772         IWorkflowInfo(self.student).fireTransition('start_clearance')
     771        IWorkflowState(self.student).setState('clearance started')
    773772        # Login as clearance officer
    774773        self.browser.open(self.login_path)
     
    857856        prmlocal = IPrincipalRoleManager(cert)
    858857        prmlocal.assignRoleToPrincipal('waeup.local.CourseAdviser100', 'mrsadvise')
    859         IWorkflowInfo(self.student).fireTransition('admit')
    860         IWorkflowInfo(self.student).fireTransition('start_clearance')
    861         IWorkflowInfo(self.student).fireTransition('request_clearance')
    862         IWorkflowInfo(self.student).fireTransition('clear')
    863         IWorkflowInfo(self.student).fireTransition('pay_first_school_fee')
     858        IWorkflowState(self.student).setState('school fee paid')
    864859        # Login as course adviser
    865860        self.browser.open(self.login_path)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/workflow.py

    r7321 r7513  
    1212from waeup.sirp.students.interfaces import IStudent
    1313from waeup.sirp.students.utils import set_returning_data
     14
     15IMPORTABLE_STATES = (ADMITTED, CLEARANCE, REQUESTED, CLEARED, PAID, RETURNING,
     16    REGISTERED, VALIDATED)
    1417
    1518REGISTRATION_TRANSITIONS = (
Note: See TracChangeset for help on using the changeset viewer.