Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow AU ABN value with spaces to validate. #267

Merged
merged 2 commits into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ New fields for existing flavors:
Modifications to existing flavors:

- Enhancements of localflavor.br.forms.BRCNPJField
(`gh-240 <https://github.com/django/django-localflavor/pull/240>`_)
(`gh-254 <https://github.com/django/django-localflavor/pull/254>`_).
(`gh-240 <https://github.com/django/django-localflavor/pull/240>`_
`gh-254 <https://github.com/django/django-localflavor/pull/254>`_).
- Fixed century bug with Kuwait Civil ID verification localflavor.kw.forms
(`gh-195 <https://github.com/django/django-localflavor/pull/195>`_).
- Allow passing field name as first positional argument of IBANField.
Expand All @@ -36,6 +36,9 @@ Modifications to existing flavors:
(`gh-250 <https://github.com/django/django-localflavor/pull/250>`_).
- Fixed the styling errors and enabled prospector
(`gh-259 <https://github.com/django/django-localflavor/pull/259>`_).
- Allow AU ABN value with spaces to validate
(`gh-266 <https://github.com/django/django-localflavor/issues/266>`_
`gh-267 <https://github.com/django/django-localflavor/pull/267>`_).

Other changes:

Expand Down Expand Up @@ -84,9 +87,9 @@ Modifications to existing flavors:
- Fix bug in ESIdentityCardNumberField where some valid values for NIE numbers were not
validating.
(`gh-217 <https://github.com/django/django-localflavor/pull/217>`_)
- Add deconstruct method to all model fields.
(`gh-162 <https://github.com/django/django-localflavor/pull/162>`_)
(`gh-224 <https://github.com/django/django-localflavor/pull/224>`_)
- Add deconstruct method to all model fields
(`gh-162 <https://github.com/django/django-localflavor/pull/162>`_
`gh-224 <https://github.com/django/django-localflavor/pull/224>`_).

Other changes:

Expand Down
5 changes: 5 additions & 0 deletions localflavor/au/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_au/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down