- Timestamp:
- 16 Apr 2012, 06:51:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/widgets/phonewidget.py
r8075 r8169 117 117 raise ConversionError( 118 118 _("Empty phone field(s)."), MissingInputError( 119 self.name, self.label, None))119 self.name, self.label, None)) 120 120 if parts[0] != '' and not RE_INT_PREFIX.match(parts[0]): 121 121 raise ConversionError( 122 122 _("Int. prefix requires format '+NNN'"), 123 123 ValueError('invalid international prefix')) 124 error1 = parts[1] != '' and not RE_NUMBERS.match(parts[1]) 125 if len(parts) == 3: 126 error2 = parts[2] != '' and not RE_NUMBERS_AND_HYPHENS.match(parts[2]) 127 else: 128 error2 = False 129 if error1 or error2: 124 # Make sure there are only numbers in parts 1..N. We do not allow 125 # dashes in last field any more. 126 errors = [(x != '' and not RE_NUMBERS.match(x)) for x in parts[1:]] 127 error = True in errors 128 if error: 130 129 raise ConversionError( 131 130 _("Phone numbers may contain numbers only."), 132 131 ValueError('non numbers in phone number')) 133 # We consider also values ending with '--' as missing values. 134 # This means that any prefix setting in the form will switch 135 # back to default upon submit if no further phone fields are filled. 136 # As advantage we get only valid phone numbers or missing value. 137 if result in ('', None) or result.endswith('--'): 132 # We consider also values ending with empty ending as missing 133 # values. An 'empty ending' is a form where the fields 134 # following the prefix are all empty. This means that any 135 # prefix setting in the form will switch back to default upon 136 # submit if no further phone fields are filled. As advantage 137 # we get only valid phone numbers or missing value. 138 empty_ending = '-'*(len(parts) - 1) 139 if result in ('', None) or result.endswith(empty_ending): 138 140 result = self.context.missing_value 139 141 return result
Note: See TracChangeset for help on using the changeset viewer.