From d6123eb52855f57b0fcdf33672ab3df3027cf26d Mon Sep 17 00:00:00 2001 From: Ben Konrath Date: Fri, 25 Nov 2016 09:08:30 +0100 Subject: [PATCH 1/2] Allow AU ABN value with spaces to validate. Fixes #266 --- docs/changelog.rst | 3 +++ localflavor/au/forms.py | 5 +++++ tests/test_au/tests.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index aef1d3423..af48c1b42 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -36,6 +36,9 @@ Modifications to existing flavors: (`gh-250 `_). - Fixed the styling errors and enabled prospector (`gh-259 `_). +- Allow AU ABN value with spaces to validate + (`gh-266 `_ + `gh-267 `_). Other changes: diff --git a/localflavor/au/forms.py b/localflavor/au/forms.py index 0029bb420..7d82573d5 100644 --- a/localflavor/au/forms.py +++ b/localflavor/au/forms.py @@ -68,10 +68,15 @@ class AUBusinessNumberField(CharField): A form field that validates input as an Australian Business Number (ABN). .. versionadded:: 1.3 + .. versionchanged:: 1.4 """ default_validators = [AUBusinessNumberFieldValidator()] + def to_python(self, value): + value = super(AUBusinessNumberField, self).to_python(value) + return value.upper().replace(' ', '') + def prepare_value(self, value): """Format the value for display.""" if value is None: diff --git a/tests/test_au/tests.py b/tests/test_au/tests.py index fff0f94af..206ba0387 100644 --- a/tests/test_au/tests.py +++ b/tests/test_au/tests.py @@ -124,9 +124,9 @@ def test_abn(self): error_format = ['Enter a valid ABN.'] valid = { '53004085616': '53004085616', + '53 004 085 616': '53004085616', } invalid = { - '53 004 085 616': error_format, '53004085617': error_format, '5300A085616': error_format, } From 9344f1d318c4e1a219c36d6bb65d60a9a20c331c Mon Sep 17 00:00:00 2001 From: Ben Konrath Date: Fri, 25 Nov 2016 09:09:06 +0100 Subject: [PATCH 2/2] Correct changelog entries with 2 gh issues. --- docs/changelog.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index af48c1b42..d41ded290 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,8 +22,8 @@ New fields for existing flavors: Modifications to existing flavors: - Enhancements of localflavor.br.forms.BRCNPJField - (`gh-240 `_) - (`gh-254 `_). + (`gh-240 `_ + `gh-254 `_). - Fixed century bug with Kuwait Civil ID verification localflavor.kw.forms (`gh-195 `_). - Allow passing field name as first positional argument of IBANField. @@ -87,9 +87,9 @@ Modifications to existing flavors: - Fix bug in ESIdentityCardNumberField where some valid values for NIE numbers were not validating. (`gh-217 `_) -- Add deconstruct method to all model fields. - (`gh-162 `_) - (`gh-224 `_) +- Add deconstruct method to all model fields + (`gh-162 `_ + `gh-224 `_). Other changes: