Changeset 7874 for main/waeup.kofa/trunk/src/waeup/kofa/utils
- Timestamp:
- 14 Mar 2012, 03:19:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r7871 r7874 38 38 return True 39 39 40 #: A list of phone prefixes (order num, country, prefix). 41 #: Items with same order num will be sorted alphabetically. 42 #: The lower the order num, the higher the precedence. 43 INT_PHONE_PREFIXES = [ 44 (99, _('Germany'), '49'), 45 ( 1, _('Nigeria'), '234'), 46 (99, _('U.S.'), '1'), 47 ] 48 49 def sorted_phone_prefixes(data = INT_PHONE_PREFIXES, request=None): 50 """Sorted tuples of phone prefixes. 51 52 Ordered as shown above and formatted for use in select boxes. 53 54 If request is given, we'll try to translate all country names in 55 order to sort alphabetically correctly. 56 57 XXX: This is a function (and not a constant) as different 58 languages might give different orders. This is not tested yet. 59 60 XXX: If we really want to use alphabetic ordering here, we might 61 think about caching results of translations. 62 """ 63 if request is not None: 64 data = [ 65 (x, translate(y, context=request), z) 66 for x, y, z in data] 67 return tuple([ 68 ('%s (+%s)' % (x[1],x[2]), '+%s' % x[2]) 69 for x in sorted(data) 70 ]) 71 40 72 class KofaUtils(grok.GlobalUtility): 41 73 """A collection of parameters and methods subject to customization. … … 57 89 } 58 90 59 INT_PHONE_PREFIXES = { 60 _('Germany'): (2, '49'), 61 _('Nigeria'): (1, '234'), 62 _('U.S.'): (3, '1'), 63 } 91 #: A function to return 92 @classmethod 93 def sorted_phone_prefixes(cls, data=INT_PHONE_PREFIXES, request=None): 94 return sorted_phone_prefixes(data, request) 64 95 65 96 EXAM_SUBJECTS_DICT = {
Note: See TracChangeset for help on using the changeset viewer.