Changeset 9776 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 6 Dec 2012, 11:23:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/vocabularies.py
r9324 r9776 36 36 nats_vocab = SimpleKofaVocabulary(*COUNTRIES) 37 37 38 def levels_from_range(start_level=None, end_level=None): 39 """Get a list of valid levels for given start/end level. 40 41 Start and end level must be numbers (or ``None``). 42 43 If no start/end level is given, return the default list of levels. 44 45 If only one of start_level or end_level is given, the result is 46 undefined. 47 """ 48 if 999 in (start_level, end_level): 49 return [999] 50 levels = [10,] + [ 51 level for level in range(100,1000,10) if level % 100 < 30] 52 if start_level is None and end_level is None: 53 return levels + [999] 54 if start_level == 10 == end_level: 55 return [10,] 56 start_level, end_level = (start_level or 10, end_level or 900) 57 levels = [x for x in levels 58 if x >= start_level and x <= (end_level + 120)] 59 return levels 60 38 61 def study_levels(context): 39 62 certificate = getattr(context, 'certificate', None) 63 start_level, end_level = (None, None) 40 64 if certificate is not None: 41 65 start_level = int(certificate.start_level) 42 66 end_level = int(certificate.end_level) 43 if start_level == 999 or end_level == 999: 44 levels = [999] 45 elif start_level == 10 and end_level == 10: 46 levels = [10,] 47 elif start_level == 10: 48 levels = [10,] + [level for level in range(100,end_level+200,10) 49 if level % 100 < 30] 50 else: 51 levels = [level for level in range(start_level,end_level+200,10) 52 if level % 100 < 30] 53 else: 54 # default level range 55 levels = [10,] 56 levels += [level for level in range(100,1000,10) if level % 100 < 30] 57 levels.append(999) 58 return levels 59 67 return levels_from_range(start_level, end_level) 60 68 61 69 class StudyLevelSource(BasicContextualSourceFactory):
Note: See TracChangeset for help on using the changeset viewer.