Ticket #12595: 12595-1-wip.diff

File 12595-1-wip.diff, 5.6 KB (added by Claude Paroz, 14 years ago)
  • django/contrib/localflavor/ar/forms.py

    diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py
    index 53721a1..57b5f8b 100644
    a b class ARPostalCodeField(RegexField):  
    2828        'invalid': _("Enter a postal code in the format NNNN or ANNNNAAA."),
    2929    }
    3030
    31     def __init__(self, *args, **kwargs):
     31    def __init__(self, max_length=8, min_length=4, *args, **kwargs):
    3232        super(ARPostalCodeField, self).__init__(r'^\d{4}$|^[A-HJ-NP-Za-hj-np-z]\d{4}\D{3}$',
    33             min_length=4, max_length=8, *args, **kwargs)
     33            max_length, min_length, *args, **kwargs)
    3434
    3535    def clean(self, value):
    3636        value = super(ARPostalCodeField, self).clean(value)
    class ARDNIField(CharField):  
    5151        'max_digits': _("This field requires 7 or 8 digits."),
    5252    }
    5353
    54     def __init__(self, *args, **kwargs):
    55         super(ARDNIField, self).__init__(max_length=10, min_length=7, *args,
     54    def __init__(self, max_length=10, min_length=7, *args, **kwargs):
     55        super(ARDNIField, self).__init__(max_length, min_length, *args,
    5656                **kwargs)
    5757
    5858    def clean(self, value):
    class ARCUITField(RegexField):  
    8181        'checksum': _("Invalid CUIT."),
    8282    }
    8383
    84     def __init__(self, *args, **kwargs):
     84    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    8585        super(ARCUITField, self).__init__(r'^\d{2}-?\d{8}-?\d$',
    86             *args, **kwargs)
     86            max_length, min_length, *args, **kwargs)
    8787
    8888    def clean(self, value):
    8989        """
  • django/contrib/localflavor/pl/forms.py

    diff --git a/django/contrib/localflavor/pl/forms.py b/django/contrib/localflavor/pl/forms.py
    index ef4a38b..8b4d2f4 100644
    a b class PLPESELField(RegexField):  
    4040        'checksum': _(u'Wrong checksum for the National Identification Number.'),
    4141    }
    4242
    43     def __init__(self, *args, **kwargs):
     43    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    4444        super(PLPESELField, self).__init__(r'^\d{11}$',
    45             max_length=None, min_length=None, *args, **kwargs)
     45            max_length, min_length, *args, **kwargs)
    4646
    4747    def clean(self, value):
    4848        super(PLPESELField, self).clean(value)
    class PLNationalIDCardNumberField(RegexField):  
    7777        'checksum': _(u'Wrong checksum for the National ID Card Number.'),
    7878    }
    7979
    80     def __init__(self, *args, **kwargs):
     80    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    8181        super(PLNationalIDCardNumberField, self).__init__(r'^[A-Za-z]{3}\d{6}$',
    82             max_length=None, min_length=None, *args, **kwargs)
     82            max_length, min_length, *args, **kwargs)
    8383
    8484    def clean(self,value):
    8585        super(PLNationalIDCardNumberField, self).clean(value)
    class PLNIPField(RegexField):  
    129129        'checksum': _(u'Wrong checksum for the Tax Number (NIP).'),
    130130    }
    131131
    132     def __init__(self, *args, **kwargs):
     132    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    133133        super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$',
    134             max_length=None, min_length=None, *args, **kwargs)
     134            max_length, min_length, *args, **kwargs)
    135135
    136136    def clean(self,value):
    137137        super(PLNIPField, self).clean(value)
    class PLREGONField(RegexField):  
    169169        'checksum': _(u'Wrong checksum for the National Business Register Number (REGON).'),
    170170    }
    171171
    172     def __init__(self, *args, **kwargs):
     172    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    173173        super(PLREGONField, self).__init__(r'^\d{9,14}$',
    174             max_length=None, min_length=None, *args, **kwargs)
     174            max_length, min_length, *args, **kwargs)
    175175
    176176    def clean(self,value):
    177177        super(PLREGONField, self).clean(value)
    class PLPostalCodeField(RegexField):  
    209209        'invalid': _(u'Enter a postal code in the format XX-XXX.'),
    210210    }
    211211
    212     def __init__(self, *args, **kwargs):
     212    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    213213        super(PLPostalCodeField, self).__init__(r'^\d{2}-\d{3}$',
    214             max_length=None, min_length=None, *args, **kwargs)
     214            max_length, min_length, *args, **kwargs)
    215215
  • tests/regressiontests/forms/localflavor/ar.py

    diff --git a/tests/regressiontests/forms/localflavor/ar.py b/tests/regressiontests/forms/localflavor/ar.py
    index 9c67269..81668b3 100644
    a b class ARLocalFlavorTests(LocalFlavorTestCase):  
    9696             '27-10345678-1': error_invalid,
    9797             u'27-10345678-1': error_invalid,
    9898        }
    99         self.assertFieldOutput(ARCUITField, valid, invalid)
     99        self.assertFieldOutput(ARCUITField, valid, invalid, field_kwargs={'max_length':15, 'min_length':4})
  • tests/regressiontests/forms/localflavor/pl.py

    diff --git a/tests/regressiontests/forms/localflavor/pl.py b/tests/regressiontests/forms/localflavor/pl.py
    index 7225abe..4a0c4c9 100644
    a b class PLLocalFlavorTests(LocalFlavorTestCase):  
    443443            '80': error_format,
    444444            '800716106AA': error_format,
    445445        }
    446         self.assertFieldOutput(PLPESELField, valid, invalid)
     446        self.assertFieldOutput(PLPESELField, valid, invalid, field_kwargs={'max_length':11, 'min_length':4})
    447447
    448448    def test_PLNationalIDCardNumberField(self):
    449449        error_checksum = [u'Wrong checksum for the National ID Card Number.']
Back to Top