Django

Code

Show
Ignore:
Timestamp:
12/17/07 02:05:27 (1 year ago)
Author:
mtredinnick
Message:

Fixed #5871 -- Factored out the validation errors in localflavor form fields. Brings them into line with the standard newforms fields. Patch from Jan Rademaker.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/localflavor/cl/forms.py

    r5876 r6926  
    2626    https://palena.sii.cl/cvc/dte/ee_empresas_emisoras.html 
    2727    """ 
     28    default_error_messages = { 
     29        'invalid': ugettext('Enter a valid Chilean RUT.'), 
     30        'strict': ugettext('Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'), 
     31        'checksum': ugettext('The Chilean RUT is not valid.'), 
     32    } 
     33 
    2834    def __init__(self, *args, **kwargs): 
    2935        if 'strict' in kwargs: 
    3036            del kwargs['strict'] 
    3137            super(CLRutField, self).__init__(r'^(\d{1,2}\.)?\d{3}\.\d{3}-[\dkK]$', 
    32                 error_message=ugettext('Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'), 
    33                         *args, **kwargs) 
     38                error_message=self.default_error_messages['strict'], *args, **kwargs) 
    3439        else: 
    3540            # In non-strict mode, accept RUTs that validate but do not exist in 
    3641            # the real world. 
    37             super(CLRutField, self).__init__(r'^[\d\.]{1,11}-?[\dkK]$', error_message=ugettext('Enter valid a Chilean RUT'), *args, **kwargs) 
     42            super(CLRutField, self).__init__(r'^[\d\.]{1,11}-?[\dkK]$', *args, **kwargs) 
    3843 
    3944    def clean(self, value): 
     
    4853            return self._format(rut, verificador) 
    4954        else: 
    50             raise ValidationError(u'The Chilean RUT is not valid.'
     55            raise ValidationError(self.error_messages['checksum']
    5156 
    5257    def _algorithm(self, rut):