Changeset 7848


Ignore:
Timestamp:
12 Mar 2012, 16:18:29 (13 years ago)
Author:
uli
Message:
  • Require format +NNN-NNN-NNNN for phone data.
  • Fix missing_value behaviour.
File:
1 edited

Legend:

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

    r7846 r7848  
    275275
    276276    def title_value_list(self):
    277         return sorted([('%s (+%s)' % (x,y), y)
     277        return sorted([('%s (+%s)' % (x,y), '+%s' % y)
    278278                       for x,y in self._data])
    279279
     280RE_INT_PREFIX = re.compile('^\+\d+')
    280281RE_NUMBERS = re.compile('^\d+$')
    281282RE_NUMBERS_AND_HYPHENS = re.compile('^[\d\-]+$')
     
    363364                _("Empty phone field(s)."), MissingInputError(
    364365                self.name, self.label, None))
    365         if not RE_NUMBERS.match(parts[1]) or not RE_NUMBERS_AND_HYPHENS.match(
    366             parts[2]):
     366        if parts[0] != '' and not RE_INT_PREFIX.match(parts[0]):
     367            raise ConversionError(
     368                _("Int. prefix requires format '+NNN'"),
     369                ValueError('invalid international prefix'))
     370        if (parts[1] != '' and not RE_NUMBERS.match(parts[1])) or (
     371            parts[2] != '' and not RE_NUMBERS_AND_HYPHENS.match(
     372            parts[2])):
    367373            raise ConversionError(
    368374                _("Phone numbers may contain numbers only."),
    369375                ValueError('non numbers in phone number'))
     376        if result in ('--', '', None):
     377            result = self.context.missing_value
    370378        return result
    371379
     
    384392                 for name in self.subwidget_names]
    385393                )
    386             if form_value == '--':
    387                 form_value = self._missing
    388394        else:
    389395            form_value = self._toFormValue(input_value)
     
    397403                return False
    398404        return True
    399 
Note: See TracChangeset for help on using the changeset viewer.