Ticket #12996: 12996.diff

File 12996.diff, 2.3 KB (added by jad, 15 years ago)

Diff for ticket #12996

  • django/contrib/localflavor/it/forms.py

     
    1414    default_error_messages = {
    1515        'invalid': _('Enter a valid zip code.'),
    1616    }
    17     def __init__(self, *args, **kwargs):
     17    def __init__(self, regex=None, max_length=None, min_length=None, error_message=None, *args, **kwargs):
    1818        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)
    2020
    2121class ITRegionSelect(Select):
    2222    """
     
    4444        'invalid': _(u'Enter a valid Social Security number.'),
    4545    }
    4646
    47     def __init__(self, *args, **kwargs):
     47    def __init__(self, regex=None, max_length=None, min_length=None, error_message=None, *args, **kwargs):
    4848        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)
    5050
    5151    def clean(self, value):
    5252        value = super(ITSocialSecurityNumberField, self).clean(value)
  • tests/regressiontests/forms/localflavor/it.py

     
    1313...
    1414ValidationError: [u'Enter a valid zip code.']
    1515
     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
    1630# ITRegionSelect #############################################################
    1731
    1832>>> from django.contrib.localflavor.it.forms import ITRegionSelect
Back to Top