Changeset 7871


Ignore:
Timestamp:
13 Mar 2012, 09:15:00 (13 years ago)
Author:
Henrik Bettermann
Message:

Enable customization of international dialing codes.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 edited

Legend:

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

    r7851 r7871  
    210210    APP_CATS_DICT = Attribute("Dict of application categories")
    211211    SEMESTER_DICT = Attribute("Dict of semesters or trimesters")
     212    INT_PHONE_PREFIXES = Attribute("Dict of international phone number prefixes")
    212213
    213214    def sendContactForm(
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r7843 r7871  
    5656        'ig':(6, u'Igbo'),
    5757        }
     58
     59    INT_PHONE_PREFIXES = {
     60            _('Germany'): (2, '49'),
     61            _('Nigeria'): (1, '234'),
     62            _('U.S.'): (3, '1'),
     63            }
    5864
    5965    EXAM_SUBJECTS_DICT = {
  • main/waeup.kofa/trunk/src/waeup/kofa/widgets/phonewidget.py

    r7870 r7871  
    3232    """
    3333
    34 INT_PHONE_PREFIXES = {
    35         _('Germany'): (2, '49'),
    36         _('Nigeria'): (1, '234'),
    37         _('U.S.'): (3, '1'),
    38         }
    39 
    4034class PhonePrefixes(grok.GlobalUtility):
    4135    grok.implements(IInternationalPhonePrefixes)
    4236
    43     _data = sorted(INT_PHONE_PREFIXES.items(), key=lambda value: value[1][0])
    44 
    4537    def title_value_list(self):
    46         return [('%s (+%s)' % (x,y[1]), '+%s' % y[1]) for x,y in self._data]
     38        try:
     39            from waeup.kofa.interfaces import IKofaUtils
     40            prefixes = getUtility(IKofaUtils).INT_PHONE_PREFIXES
     41            data = sorted(prefixes.items(), key=lambda value: value[1][0])
     42        except:
     43            data = [('Country of Nowhere',(1, '234'))]
     44        return [('%s (+%s)' % (x,y[1]), '+%s' % y[1]) for x,y in data]
    4745
    4846RE_INT_PREFIX = re.compile('^\+\d+')
Note: See TracChangeset for help on using the changeset viewer.