Ignore:
Timestamp:
5 Oct 2012, 05:42:19 (12 years ago)
Author:
Henrik Bettermann
Message:

Set validated_by when bypassing course validation. Declare validated_by and bypass_validation in IStudentVerdictUpdate.

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

    r9295 r9296  
    2828from time import time
    2929from datetime import datetime
     30from zope.i18n import translate
    3031from zope.interface import Interface
    3132from zope.schema import getFields
     
    3738    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount,
    3839    IObjectHistory, VALIDATED, REGISTERED, IGNORE_MARKER)
     40from waeup.kofa.interfaces import IKofaUtils
    3941from waeup.kofa.interfaces import MessageFactory as _
    4042from waeup.kofa.students.interfaces import (
     
    721723        'current_session',
    722724        'current_level',
    723         'bypass_validation']
     725        'bypass_validation',
     726        'validated_by']
    724727
    725728    def checkUpdateRequirements(self, obj, row, site):
     
    741744            return 'Study level object is missing.'
    742745        # Check if student is in state REGISTERED or VALIDATED
    743         if row.get('bypass_validation') in ('1', 'True', 'TRUE', 'yes'):
     746        if row.get('bypass_validation'):
    744747            if obj.student.state not in (VALIDATED, REGISTERED):
    745748                return 'Student in wrong state.'
     
    760763        level_string = str(obj.current_level)
    761764        obj[level_string].level_verdict = row['current_verdict']
    762         # Fire transition depending on student's state
     765        # Fire transition and set studylevel attributes
     766        # depending on student's state
    763767        if obj.__parent__.state == REGISTERED:
     768            validated_by = row.get('validated_by', '')
     769            if validated_by in (IGNORE_MARKER, ''):
     770                portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     771                system = translate(_('System'),'waeup.kofa',
     772                                  target_language=portal_language)
     773                obj[level_string].validated_by = system
     774            else:
     775                obj[level_string].validated_by = validated_by
     776            obj[level_string].validation_date = datetime.utcnow()
    764777            IWorkflowInfo(obj.__parent__).fireTransition('bypass_validation')
    765             obj[level_string].validated_by = _('System')
    766             obj[level_string].validation_date = datetime.utcnow()
    767778        else:
    768779            IWorkflowInfo(obj.__parent__).fireTransition('return')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9257 r9296  
    423423        )
    424424
     425    bypass_validation = schema.Bool(
     426        title = _(u'Bypass validation'),
     427        required = False,
     428        )
     429
     430    validated_by = schema.TextLine(
     431        title = _(u'Validated by'),
     432        required = False,
     433        )
     434
    425435class IStudentStudyLevel(IKofaObject):
    426436    """A container for course tickets.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv

    r9293 r9296  
    88X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated
    99X222222,Thomas,Kinderman,8,1990-01-02,100007,aa@aa.ng,1234,m,courses validated
     10X333333,Paula,Schall,9,1990-01-02,100008,aa@aa.ng,1234,m,courses registered
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studycourse_data.csv

    r9293 r9296  
    997,,CERT1,2008,200
    10108,,CERT1,2008,200
     119,,CERT1,2008,200
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studylevel_data.csv

    r9293 r9296  
    10106,,2008,A,200
    11117,,2008,A,200
     129,,2008,A,200
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_verdict_data.csv

    r9293 r9296  
    1 matric_number,current_session,current_level,current_verdict,bypass_validation
    2 100000,2008,200,0,0
    3 100001,2008,100,B,False
    4 100002,2007,200,C,
    5 100003,2008,200,A,
    6 100004,2008,200,,
    7 100005,2008,200,A,1
    8 100006,2008,200,A,True
    9 100007,2008,200,A,True
     1matric_number,current_session,current_level,current_verdict,bypass_validation,validated_by
     2100000,2008,200,0,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,
     9100007,2008,200,A,True,
     10100008,2008,200,A,True,Juliana
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9295 r9296  
    360360            self.csv_file, STUDENT_HEADER_FIELDS)
    361361        self.assertEqual(num_warns,0)
    362         self.assertEqual(len(self.app['students']), 9)
     362        self.assertEqual(len(self.app['students']), 10)
    363363        self.assertEqual(self.app['students']['X666666'].reg_number,'1')
    364364        self.assertEqual(
     
    980980        num, num_warns, fin_file, fail_file = self.processor.doImport(
    981981            self.csv_file, VERDICT_HEADER_FIELDS,'update')
    982         content = open(fail_file).read()
     982        #content = open(fail_file).read()
     983        #import pdb; pdb.set_trace()
    983984        self.assertEqual(num_warns,5)
    984985        self.assertEqual(studycourse.current_verdict, '0')
     
    994995        self.assertTrue(isinstance(
    995996            student['studycourse']['200'].validation_date, datetime.datetime))
     997        student = self.processor.getParent(
     998            dict(matric_number='100008'), self.app)
     999        self.assertEqual(student['studycourse']['200'].validated_by, 'Juliana')
    9961000        content = open(fail_file).read()
    9971001        self.assertEqual(
    9981002            content,
    999             'current_session,current_verdict,bypass_validation,'
    1000             'matric_number,current_level,--ERRORS--\r\n'
    1001             '2008,B,False,100001,100,Current level does not correspond.\r\n'
    1002             '2007,C,<IGNORE>,100002,200,Current session does not correspond.\r\n'
    1003             '2008,A,<IGNORE>,100003,200,Student in wrong state.\r\n'
    1004             '2008,<IGNORE>,<IGNORE>,100004,200,No verdict in import file.\r\n'
    1005             '2008,A,True,100007,200,Study level object is missing.\r\n'
     1003            'current_session,current_level,bypass_validation,current_verdict,'
     1004            'matric_number,validated_by,--ERRORS--\r\n'
     1005            '2008,100,False,B,100001,<IGNORE>,Current level does not correspond.\r\n'
     1006            '2007,200,<IGNORE>,C,100002,<IGNORE>,Current session does not correspond.\r\n'
     1007            '2008,200,<IGNORE>,A,100003,<IGNORE>,Student in wrong state.\r\n'
     1008            '2008,200,<IGNORE>,<IGNORE>,100004,<IGNORE>,No verdict in import file.\r\n'
     1009            '2008,200,True,A,100007,<IGNORE>,Study level object is missing.\r\n'
    10061010            )
    10071011        logcontent = open(self.logfile).read()
Note: See TracChangeset for help on using the changeset viewer.