Ticket #10756: ticket10756-2.diff

File ticket10756-2.diff, 3.1 KB (added by Claude Paroz, 13 years ago)

Updated to current trunk

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

    diff --git a/django/contrib/localflavor/pl/forms.py b/django/contrib/localflavor/pl/forms.py
    index ffa9ec4..3e8d73f 100644
    a b class PLNationalIDCardNumberField(RegexField):  
    122122class PLNIPField(RegexField):
    123123    """
    124124    A form field that validates as Polish Tax Number (NIP).
    125     Valid forms are: XXX-XXX-YY-YY or XX-XX-YYY-YYY.
     125    Valid forms are: XXX-YYY-YY-YY, XXX-YY-YY-YYY or XXXYYYYYYY.
    126126
    127127    Checksum algorithm based on documentation at
    128128    http://wipos.p.lodz.pl/zylla/ut/nip-rego.html
    129129    """
    130130    default_error_messages = {
    131         'invalid': _(u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.'),
     131        'invalid': _(u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.'),
    132132        'checksum': _(u'Wrong checksum for the Tax Number (NIP).'),
    133133    }
    134134
    135135    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
    136         super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$',
     136        super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$|^\d{10}$',
    137137            max_length, min_length, *args, **kwargs)
    138138
    139139    def clean(self,value):
  • docs/ref/contrib/localflavor.txt

    diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt
    index 4671906..1593598 100644
    a b Poland (``pl``)  
    960960
    961961.. class:: pl.forms.PLNIPField
    962962
    963     A form field that validates input as a Polish Tax Number (NIP). Valid
    964     formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX. The checksum algorithm used
     963    A form field that validates input as a Polish Tax Number (NIP). Valid formats
     964    are XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX. The checksum algorithm used
    965965    for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
    966966
    967967.. class:: pl.forms.PLCountySelect
  • tests/regressiontests/localflavor/pl/tests.py

    diff --git a/tests/regressiontests/localflavor/pl/tests.py b/tests/regressiontests/localflavor/pl/tests.py
    index 8c7af38..52154f8 100644
    a b class PLLocalFlavorTests(SimpleTestCase):  
    420420        self.assertFieldOutput(PLPostalCodeField, valid, invalid)
    421421
    422422    def test_PLNIPField(self):
    423         error_format = [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.']
     423        error_format = [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.']
    424424        error_checksum = [u'Wrong checksum for the Tax Number (NIP).']
    425425        valid = {
    426             '64-62-414-124': '6462414124',
    427426            '646-241-41-24': '6462414124',
     427            '646-24-14-124': '6462414124',
     428            '6462414124': '6462414124',
    428429        }
    429430        invalid = {
    430431            '43-343-234-323': error_format,
     432            '64-62-414-124': error_format,
    431433            '646-241-41-23': error_checksum,
    432434        }
    433435        self.assertFieldOutput(PLNIPField, valid, invalid)
Back to Top