Ignore:
Timestamp:
4 Oct 2012, 05:38:17 (12 years ago)
Author:
Henrik Bettermann
Message:

Extend verdict processor. Allow bypassing course validation if rowbypass_validation? is 'True' or '1'.

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

Legend:

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

    r9282 r9284  
    3535from waeup.kofa.interfaces import (
    3636    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount,
    37     IObjectHistory, VALIDATED, IGNORE_MARKER)
     37    IObjectHistory, VALIDATED, REGISTERED, IGNORE_MARKER)
    3838from waeup.kofa.interfaces import MessageFactory as _
    3939from waeup.kofa.students.interfaces import (
     
    717717    factory_name = 'waeup.StudentStudyCourse'
    718718
    719     additional_fields = ['current_session', 'current_level']
     719    additional_fields = [
     720        'current_session',
     721        'current_level',
     722        'bypass_validation']
    720723
    721724    def checkUpdateRequirements(self, obj, row, site):
     
    729732        if obj.current_session != row['current_session']:
    730733            return 'Current session does not correspond.'
    731         # Check if student is in state REGISTERED
    732         if obj.student.state != VALIDATED:
    733             return 'Student in wrong state.'
    734734        # Check if new verdict is provided
    735735        if row['current_verdict'] in (IGNORE_MARKER, ''):
    736736            return 'Verdict is missing.'
     737        # Check if student is in state REGISTERED or VALIDATED
     738        if row.get('bypass_validation') in ('1', 'True', 'TRUE', 'yes'):
     739            if obj.student.state not in (VALIDATED, REGISTERED):
     740                return 'Student in wrong state.'
     741        else:
     742            if obj.student.state != VALIDATED:
     743                return 'Student in wrong state.'
    737744        return None
    738745
     
    749756            '%s - Verdict updated: %s'
    750757            % (parent.student_id, items_changed))
    751         # Fire transition
    752         IWorkflowInfo(obj.__parent__).fireTransition('return')
     758        # Fire transition depending on student's state
     759        if obj.__parent__.state == REGISTERED:
     760            IWorkflowInfo(obj.__parent__).fireTransition('bypass_validation')
     761        else:
     762            IWorkflowInfo(obj.__parent__).fireTransition('return')
    753763        # Update the students_catalog
    754764        notify(grok.ObjectModifiedEvent(obj.__parent__))
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv

    r9282 r9284  
    33Y777777,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
    5 ,Else,Mueller,4,1990-01-05,100003,aa@aa.ng,1234,f,courses registered
     5,Else,Mueller,4,1990-01-05,100003,aa@aa.ng,1234,f,school fee paid
    66X888888,Alfons,Meier,5,1990-01-02,100004,aa@aa.ng,1234,m,courses validated
     7X999999,Herbert,Mueller,6,1990-01-02,100005,aa@aa.ng,1234,m,courses registered
     8X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data_update3.csv

    r8309 r9284  
    33Y777777,,return
    44,3,return
    5 ,4,validate_courses
     5,4,register_courses
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studycourse_data.csv

    r9282 r9284  
    664,,CERT1,2008,200
    775,,CERT1,2008,200
     86,,CERT1,2008,200
     97,,CERT1,2008,200
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_verdict_data.csv

    r9282 r9284  
    1 matric_number,current_session,current_level,current_verdict
    2 100000,2008,200,A
    3 100001,2008,100,B
    4 100002,2007,200,C
    5 100003,2008,200,A
    6 100004,2008,200,
     1matric_number,current_session,current_level,current_verdict,bypass_validation
     2100000,2008,200,A,0
     3100001,2008,100,B,False
     4100002,2007,200,C,
     5100003,2008,200,A,
     6100004,2008,200,,
     7100005,2008,200,A,1
     8100006,2008,200,A,True
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9283 r9284  
    360360            self.csv_file, STUDENT_HEADER_FIELDS)
    361361        self.assertEqual(num_warns,0)
    362         assert len(self.app['students'].keys()) == 6
     362        self.assertEqual(len(self.app['students']), 8)
    363363        self.assertEqual(self.app['students']['X666666'].reg_number,'1')
    364364        self.assertEqual(
     
    612612        self.assertEqual(student.state, 'returning')
    613613        self.assertEqual(studycourse.current_level, 200)
     614        student = self.processor.getParent(
     615            dict(matric_number='100005'), self.app)
     616        self.assertEqual(studycourse.current_verdict, 'A')
     617        self.assertEqual(student.state, 'returning')
     618        self.assertEqual(studycourse.current_level, 200)
    614619        content = open(fail_file).read()
    615620        self.assertEqual(
    616621            content,
    617             'current_session,current_verdict,matric_number,current_level,--ERRORS--\r\n'
    618             '2008,B,100001,100,Current level does not correspond.\r\n'
    619             '2007,C,100002,200,Current session does not correspond.\r\n'
    620             '2008,A,100003,200,Student in wrong state.\r\n'
    621             '2008,<IGNORE>,100004,200,Verdict is missing.\r\n'
     622            'current_session,current_verdict,bypass_validation,'
     623            'matric_number,current_level,--ERRORS--\r\n'
     624            '2008,B,False,100001,100,Current level does not correspond.\r\n'
     625            '2007,C,<IGNORE>,100002,200,Current session does not correspond.\r\n'
     626            '2008,A,<IGNORE>,100003,200,Student in wrong state.\r\n'
     627            '2008,<IGNORE>,<IGNORE>,100004,200,Verdict is missing.\r\n'
    622628            )
    623629        shutil.rmtree(os.path.dirname(fin_file))
  • main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py

    r9161 r9284  
    164164
    165165    Transition(
     166        transition_id = 'bypass_validation',
     167        title = _('Return and bypass validation'),
     168        msg = _("Returned"),
     169        source = REGISTERED,
     170        destination = RETURNING),
     171
     172    Transition(
    166173        transition_id = 'reset8',
    167174        title = _('Reset to school fee paid'),
     
    173180        transition_id = 'return',
    174181        title = _('Return'),
    175         msg = _("Reset to 'returning'"),
     182        msg = _("Returned"),
    176183        source = VALIDATED,
    177184        destination = RETURNING),
Note: See TracChangeset for help on using the changeset viewer.