Changeset 7532


Ignore:
Timestamp:
28 Jan 2012, 14:19:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Use fixed start_level and end_level if no certificate has yet been assigned. This way, we can import certificate end current_level at the same time.

Extend conversion checking so that current_level does not exceed level limits given by the certificate.

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

Legend:

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

    r7522 r7532  
    3636    IObjectHistory)
    3737from waeup.sirp.students.interfaces import (
    38     IStudent, IStudentStudyCourseImport,
     38    IStudent, IStudentStudyCourse,
    3939    IStudentUpdateByRegNo, IStudentUpdateByMatricNo)
    4040from waeup.sirp.students.workflow import  IMPORTABLE_STATES
     
    214214
    215215    name = u'StudentStudyCourse Importer (update only)'
    216     iface = IStudentStudyCourseImport
     216    iface = IStudentStudyCourse
    217217    factory_name = 'waeup.StudentStudyCourse'
    218218
     
    293293        return
    294294
     295    def checkConversion(self, row, mode='ignore'):
     296        """Validates all values in row.
     297        """
     298        converter = IObjectConverter(self.iface)
     299        errs, inv_errs, conv_dict =  converter.fromStringDict(
     300            row, self.factory_name)
     301        # We have to check if current_level is in range of certificate.
     302        # This is not done by the converter.
     303        certificate = conv_dict['certificate']
     304        start_level = certificate.start_level
     305        end_level = certificate.end_level
     306        if conv_dict['current_level'] < start_level or \
     307            conv_dict['current_level'] > end_level:
     308            errs.append(('current_level','not in range'))
     309        return errs, inv_errs, conv_dict
     310
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r7523 r7532  
    305305        )
    306306
    307 class IStudentStudyCourseImport(IStudentStudyCourse):
    308     """A container for student study levels.
    309 
    310     """
    311     current_level = schema.Int(
    312         title = u'Current Level',
    313         default = None,
    314         )
    315 
    316307class IStudentStudyLevel(ISIRPObject):
    317308    """A container for course tickets.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py

    r7523 r7532  
    3737
    3838def study_levels(studycourse):
    39     try:
     39    if studycourse.certificate is not None:
    4040        start_level = int(studycourse.certificate.start_level)
    4141        end_level = int(studycourse.certificate.end_level)
    42         levels = [level for level in range(start_level,end_level+200,10)
    43                    if level % 100 < 30 and level < end_level + 120]
    44         return levels
    45     except AttributeError:
    46         return []
     42    else:
     43        start_level = 0
     44        end_level = 600
     45    levels = [level for level in range(start_level,end_level+200,10)
     46               if level % 100 < 30 and level < end_level + 120]
     47    return levels
     48
    4749
    4850class StudyLevelSource(BasicContextualSourceFactory):
     
    6062
    6163    def getTitle(self, context, value):
    62         end_level = int(context.certificate.end_level)
     64        if context.certificate is not None:
     65            end_level = int(context.certificate.end_level)
     66        else:
     67            end_level = 600
    6368        level,repeat = divmod(value, 100)
    6469        level = level * 100
Note: See TracChangeset for help on using the changeset viewer.