Ignore:
Timestamp:
31 Aug 2012, 14:54:18 (12 years ago)
Author:
Henrik Bettermann
Message:

When transferring students StudyLevelSource? will be called in the context of a student. Thus study_levels is not necessarily a function of a studycourse.

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

Legend:

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

    r7811 r9133  
    2121
    2222
    23 class FakeStudyCourse(object):
     23class FakeStudyCourse(dict):
    2424
    25     def __init__(self):
     25    def __init__(object):
    2626        cert = Certificate(code="CERT1")
    2727        cert.start_level = 100
    2828        cert.end_level = 500
    2929        self.certificate = cert
     30
     31    def get(self, attr, default=None):
     32        try:
     33            return self.__getattribute__(attr)
     34        except AttributeError:
     35            return default
    3036
    3137class VocabularyTests(unittest.TestCase):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/vocabularies.py

    r8940 r9133  
    3636nats_vocab = SimpleKofaVocabulary(*COUNTRIES)
    3737
    38 def study_levels(studycourse):
    39     if studycourse.certificate is not None:
    40         start_level = int(studycourse.certificate.start_level)
    41         end_level = int(studycourse.certificate.end_level)
     38def study_levels(context):
     39    if context.get('certificate', None) is not None:
     40        start_level = int(context.certificate.start_level)
     41        end_level = int(context.certificate.end_level)
    4242        if start_level == 999 or end_level == 999:
    4343            levels = [999]
     
    6969
    7070    def getTitle(self, context, value):
    71         if context.certificate is not None:
     71        if context.get('certificate', None) is not None:
    7272            start_level = int(context.certificate.start_level)
    7373            end_level = int(context.certificate.end_level)
     
    8080                return _('Error: wrong level id ${value}',
    8181                    mapping={'value': value})
     82        if value == 999:
    8283            return course_levels.by_value[999].title
    8384        if value < start_level or value > end_level + 120:
Note: See TracChangeset for help on using the changeset viewer.