Ticket #9259: 9259.diff
File 9259.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/localflavor/es/forms.py
76 76 self.cif_control = 'JABCDEFGHI' 77 77 self.cif_types = 'ABCDEFGHKLMNPQS' 78 78 self.nie_types = 'XT' 79 super(ESIdentityCardNumberField, self).__init__(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types + self.cif_types.lower() + self.nie_types.lower(), self.nif_control + self.nif_control.lower()),80 79 id_card_re = re.compile(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types, self.nif_control + self.cif_control), re.IGNORECASE) 80 super(ESIdentityCardNumberField, self).__init__(id_card_re, max_length=None, min_length=None, 81 81 error_message=self.default_error_messages['invalid%s' % (self.only_nif and '_only_nif' or '')], 82 82 *args, **kwargs) 83 83 … … 88 88 nif_get_checksum = lambda d: self.nif_control[int(d)%23] 89 89 90 90 value = value.upper().replace(' ', '').replace('-', '') 91 m = re.match(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types, self.nif_control ), value)91 m = re.match(r'^([%s]?)[ -]?(\d+)[ -]?([%s]?)$' % (self.cif_types + self.nie_types, self.nif_control + self.cif_control), value) 92 92 letter1, number, letter2 = m.groups() 93 93 94 94 if not letter1 and letter2: -
tests/regressiontests/forms/localflavor/es.py
157 157 'X3287690R' 158 158 >>> f.clean('t-03287690r') 159 159 'T03287690R' 160 >>> f.clean('P2907500I') 161 'P2907500I' 160 162 >>> f.clean('X-03287690') 161 163 Traceback (most recent call last): 162 164 ...