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'.

File:
1 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__))
Note: See TracChangeset for help on using the changeset viewer.