Ignore:
Timestamp:
28 Nov 2012, 07:52:56 (12 years ago)
Author:
Henrik Bettermann
Message:

Current level must be in range of certificate. This must be checked in checkUpdateRequirements.

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

Legend:

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

    r9706 r9735  
    455455        """
    456456        current_level = row.get('current_level', None)
    457         if current_level == 999 and \
    458             obj.__parent__.state in FORBIDDEN_POSTGRAD_STATES:
    459             return 'Not a pg student.'
     457        if current_level:
     458            if current_level == 999 and \
     459                obj.__parent__.state in FORBIDDEN_POSTGRAD_STATES:
     460                return 'Not a pg student.'
     461            certificate = getattr(obj, 'certificate', None)
     462            cert = row.get('certificate', None)
     463            if certificate is None and cert is None:
     464                return 'No certificate to check level.'
     465            if certificate is not None and (
     466                current_level < certificate.start_level or \
     467                current_level > certificate.end_level+120):
     468                return 'current_level not in range.'
    460469        return None
    461470
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9706 r9735  
    575575
    576576    def test_checkUpdateRequirements(self):
    577         # Make sure that pg students can't be updated with wrong transition.
     577        # Current level must be in range of certificate.
     578        # Since row has passed the converter, current_level is an integer.
    578579        err = self.processor.checkUpdateRequirements(
    579580            self.student['studycourse'],
    580             dict(reg_number='1', current_level='100'), self.app)
     581            dict(reg_number='1', current_level=100), self.app)
     582        self.assertEqual(err, 'current_level not in range.')
     583        err = self.processor.checkUpdateRequirements(
     584            self.student['studycourse'],
     585            dict(reg_number='1', current_level=200), self.app)
    581586        self.assertTrue(err is None)
    582         # Since row has passed the converter, current_level is an integer.
     587        # We can update pg students.
     588        self.student['studycourse'].certificate.start_level=999
     589        self.student['studycourse'].certificate.end_level=999
    583590        err = self.processor.checkUpdateRequirements(
    584591            self.student['studycourse'],
    585592            dict(reg_number='1', current_level=999), self.app)
    586593        self.assertTrue(err is None)
     594        # Make sure that pg students can't be updated with wrong transition.
    587595        IWorkflowState(self.student).setState('returning')
    588596        err = self.processor.checkUpdateRequirements(
     
    590598            dict(reg_number='1', current_level=999), self.app)
    591599        self.assertEqual(err, 'Not a pg student.')
     600        # If certificate is not given in row (and has thus
     601        # successfully passed checkConversion) the certificate
     602        # attribute must be set.
     603        self.student['studycourse'].certificate = None
     604        err = self.processor.checkUpdateRequirements(
     605            self.student['studycourse'],
     606            dict(reg_number='1', current_level=100), self.app)
     607        self.assertEqual(err, 'No certificate to check level.')
    592608
    593609    def test_import(self):
Note: See TracChangeset for help on using the changeset viewer.