Ticket #12996: 12996.diff
File 12996.diff, 2.3 KB (added by , 15 years ago) |
---|
-
django/contrib/localflavor/it/forms.py
14 14 default_error_messages = { 15 15 'invalid': _('Enter a valid zip code.'), 16 16 } 17 def __init__(self, *args, **kwargs):17 def __init__(self, regex=None, max_length=None, min_length=None, error_message=None, *args, **kwargs): 18 18 super(ITZipCodeField, self).__init__(r'^\d{5}$', 19 max_length =None, min_length=None, *args, **kwargs)19 max_length, min_length, error_message, *args, **kwargs) 20 20 21 21 class ITRegionSelect(Select): 22 22 """ … … 44 44 'invalid': _(u'Enter a valid Social Security number.'), 45 45 } 46 46 47 def __init__(self, *args, **kwargs):47 def __init__(self, regex=None, max_length=None, min_length=None, error_message=None, *args, **kwargs): 48 48 super(ITSocialSecurityNumberField, self).__init__(r'^\w{3}\s*\w{3}\s*\w{5}\s*\w{5}$', 49 max_length =None, min_length=None, *args, **kwargs)49 max_length, min_length, error_message, *args, **kwargs) 50 50 51 51 def clean(self, value): 52 52 value = super(ITSocialSecurityNumberField, self).clean(value) -
tests/regressiontests/forms/localflavor/it.py
13 13 ... 14 14 ValidationError: [u'Enter a valid zip code.'] 15 15 16 # ITZipCodeField max/min length, error_message test 17 18 >>> from django.contrib.localflavor.it.forms import ITZipCodeField 19 >>> form1 = ITZipCodeField(max_length=65) 20 >>> form2 = ITZipCodeField(min_length=65) 21 >>> form3 = ITZipCodeField(error_message=u'Error Message') 22 23 # ITSocialSecurityNumberField max/min length, error_message test 24 25 >>> from django.contrib.localflavor.it.forms import ITSocialSecurityNumberField 26 >>> form1 = ITSocialSecurityNumberField(max_length=65) 27 >>> form2 = ITSocialSecurityNumberField(min_length=65) 28 >>> form3 = ITSocialSecurityNumberField(error_message=u'Error Message') 29 16 30 # ITRegionSelect ############################################################# 17 31 18 32 >>> from django.contrib.localflavor.it.forms import ITRegionSelect