Skip to content

Commit

Permalink
Removed deprecated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
benkonrath committed Dec 8, 2017
1 parent b3d10ed commit dc6702d
Show file tree
Hide file tree
Showing 75 changed files with 93 additions and 2,457 deletions.
49 changes: 48 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
2.0 (unreleased)
------------------

All deprecated code has been removed in this release. See details below.

New flavors:

- None
Expand All @@ -23,7 +25,52 @@ Other changes:
- Added support for Django 2.0 and dropped support for Django < 1.11
(`gh-310 <https://github.com/django/django-localflavor/pull/310>`_).
- Fixed README and changelog documentation about dropping Python 2 and Django 1.11.

- Removed the following deprecated items
(`gh-321 <https://github.com/django/django-localflavor/pull/321>`_):

- `au.forms.AUPhoneNumberField`
- `au.models.AUPhoneNumberField`
- `be.forms.BEPhoneNumberField`
- `br.forms.BRPhoneNumberField`
- `br.forms.DV_maker`
- `ca.forms.CAPhoneNumberField`
- `ch.forms.CHPhoneNumberField`
- `cn.forms.CNPhoneNumberField`
- `cn.forms.CNCellNumberField`
- `dk.forms.DKPhoneNumberField`
- `es.forms.ESPhoneNumberField`
- `fr.forms.FRPhoneNumberField`
- `gr.forms.GRPhoneNumberField`
- `gr.forms.GRMobilePhoneNumberField`
- `hk.forms.HKPhoneNumberField` (`localflavor.hk` has been removed because it only contained this field)
- `hr.forms.HRPhoneNumberField`
- `id_.forms.IDPhoneNumberField`
- `il.forms.ILMobilePhoneNumberField`
- `in.forms.INPhoneNumberField`
- `is_.forms.ISPhoneNumberField`
- `it.forms.ITPhoneNumberField`
- `lt.forms.LTPhoneField`
- `nl.forms.NLPhoneNumberField`
- `nl.forms.NLSoFiNumberField`
- `nl.models.NLBankAccountNumberField`
- `nl.models.NLPhoneNumberField`
- `nl.models.NLSoFiNumberField`
- `nl.validators.NLBankAccountNumberFieldValidator`
- `nl.validators.NLPhoneNumberFieldValidator`
- `nl.validators.NLSoFiNumberFieldValidator`
- `no.forms.NOPhoneNumberField`
- `nz.forms.NZPhoneNumberField`
- `pk.forms.PKPhoneNumberField`
- `pk.models.PKPhoneNumberField`
- `pt.forms.PTPhoneNumberField`
- `ro.forms.ROIBANField`
- `ro.forms.ROPhoneNumberField`
- `sg.forms.SGPhoneNumberField`
- `sg.forms.SGNRIC_FINField`
- `si.forms.SIPhoneNumberField`
- `tr.forms.TRPhoneNumberField`
- `us.forms.USPhoneNumberField`
- `us.models.PhoneNumberField`

1.6 (2017-11-22)
------------------
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ validate Finnish social security numbers.
* :doc:`localflavor/fr`
* :doc:`localflavor/gb`
* :doc:`localflavor/gr`
* :doc:`localflavor/hk`
* :doc:`localflavor/hr`
* :doc:`localflavor/hu`
* :doc:`localflavor/id_`
Expand Down
8 changes: 0 additions & 8 deletions docs/localflavor/hk.rst

This file was deleted.

32 changes: 0 additions & 32 deletions localflavor/au/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@

import re

from django.forms import ValidationError
from django.forms.fields import CharField, RegexField, Select
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberFormFieldMixin

from .au_states import STATE_CHOICES
from .validators import AUBusinessNumberFieldValidator, AUCompanyNumberFieldValidator, AUTaxFileNumberFieldValidator

Expand All @@ -33,34 +29,6 @@ def __init__(self, max_length=4, *args, **kwargs):
super(AUPostCodeField, self).__init__(r'^\d{4}$', max_length=max_length, *args, **kwargs)


class AUPhoneNumberField(CharField, DeprecatedPhoneNumberFormFieldMixin):
"""
A form field that validates input as an Australian phone number.
Valid numbers have ten digits.
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

default_error_messages = {
'invalid': 'Phone numbers must contain 10 digits.',
}

def clean(self, value):
"""Validate a phone number. Strips parentheses, whitespace and hyphens."""
super(AUPhoneNumberField, self).clean(value)
if value in self.empty_values:
return self.empty_value
value = re.sub('(\(|\)|\s+|-)', '', force_text(value))
phone_match = PHONE_DIGITS_RE.search(value)
if phone_match:
return '%s' % phone_match.group(1)
raise ValidationError(self.error_messages['invalid'])


class AUStateSelect(Select):
"""A Select widget that uses a list of Australian states/territories as its choices."""

Expand Down
24 changes: 0 additions & 24 deletions localflavor/au/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.db.models import CharField
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberField

from . import forms
from .au_states import STATE_CHOICES
from .validators import AUBusinessNumberFieldValidator, AUCompanyNumberFieldValidator, AUTaxFileNumberFieldValidator
Expand Down Expand Up @@ -47,28 +45,6 @@ def formfield(self, **kwargs):
return super(AUPostCodeField, self).formfield(**defaults)


class AUPhoneNumberField(CharField, DeprecatedPhoneNumberField):
"""
A model field that checks that the value is a valid Australian phone number (ten digits).
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

description = _("Australian Phone number")

def __init__(self, *args, **kwargs):
kwargs['max_length'] = 20
super(AUPhoneNumberField, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
defaults = {'form_class': forms.AUPhoneNumberField}
defaults.update(kwargs)
return super(AUPhoneNumberField, self).formfield(**defaults)


class AUBusinessNumberField(CharField):
"""
A model field that checks that the value is a valid Australian Business Number (ABN).
Expand Down
43 changes: 0 additions & 43 deletions localflavor/be/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberFormFieldMixin

from .be_provinces import PROVINCE_CHOICES
from .be_regions import REGION_CHOICES

Expand All @@ -29,47 +27,6 @@ def __init__(self, *args, **kwargs):
super(BEPostalCodeField, self).__init__(r'^[1-9]\d{3}$', *args, **kwargs)


class BEPhoneNumberField(RegexField, DeprecatedPhoneNumberFormFieldMixin):
"""
A form field that validates its input as a belgium phone number.
Landlines have a seven-digit subscriber number and a one-digit area code,
while smaller cities have a six-digit subscriber number and a two-digit
area code. Cell phones have a six-digit subscriber number and a two-digit
area code preceeded by the number 4.
0d ddd dd dd, 0d/ddd.dd.dd, 0d.ddd.dd.dd,
0dddddddd - dialling a bigger city
0dd dd dd dd, 0dd/dd.dd.dd, 0dd.dd.dd.dd,
0dddddddd - dialling a smaller city
04dd ddd dd dd, 04dd/ddd.dd.dd,
04dd.ddd.dd.dd, 04ddddddddd - dialling a mobile number
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

default_error_messages = {
'invalid': _('Enter a valid phone number in one of the formats '
'0x xxx xx xx, 0xx xx xx xx, 04xx xx xx xx, '
'0x/xxx.xx.xx, 0xx/xx.xx.xx, 04xx/xx.xx.xx, '
'0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx, '
'0xxxxxxxx or 04xxxxxxxx.'),
}

def __init__(self, *args, **kwargs):
super(BEPhoneNumberField, self).__init__(r'^[0]\d{1}[/. ]?'
r'\d{3}[. ]\d{2}[. ]?'
r'\d{2}$|^[0]\d{2}[/. ]?'
r'\d{2}[. ]?\d{2}[. ]?'
r'\d{2}$|^[0][4]\d{2}[/. ]?'
r'\d{2}[. ]?'
r'\d{2}[. ]?'
r'\d{2}$',
*args, **kwargs)


class BERegionSelect(Select):
"""A Select widget that uses a list of belgium regions as its choices."""

Expand Down
40 changes: 0 additions & 40 deletions localflavor/br/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
from __future__ import unicode_literals

import re
import warnings

from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import CharField, Field, RegexField, Select
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberFormFieldMixin, RemovedInLocalflavor20Warning

from .br_states import STATE_CHOICES

phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4,5})[-\.]?(\d{4})$')
Expand All @@ -37,34 +34,6 @@ def __init__(self, *args, **kwargs):
super(BRZipCodeField, self).__init__(r'^\d{5}-\d{3}$', *args, **kwargs)


class BRPhoneNumberField(Field, DeprecatedPhoneNumberFormFieldMixin):
"""
A form field that validates input as a Brazilian phone number.
The phone number must be in either of the following formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

default_error_messages = {
'invalid': _(('Phone numbers must be in either of the following '
'formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.')),
}

def clean(self, value):
super(BRPhoneNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = re.sub('(\(|\)|\s+)', '', force_text(value))
m = phone_digits_re.search(value)
if m:
return '%s-%s-%s' % (m.group(1), m.group(2), m.group(3))
raise ValidationError(self.error_messages['invalid'])


class BRStateSelect(Select):
"""A Select widget that uses a list of Brazilian states/territories as its choices."""

Expand Down Expand Up @@ -103,15 +72,6 @@ def dv_maker(v):
return 0


def DV_maker(v): # noqa
"""
.. deprecated:: 1.6
Use `dv_maker` instead.
"""
warnings.warn('DV_maker is deprecated. Please use dv_maker instead.', RemovedInLocalflavor20Warning)
return dv_maker(v)


class BRCPFField(CharField):
"""
A form field that validates a CPF number or a CPF string.
Expand Down
27 changes: 0 additions & 27 deletions localflavor/ca/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import CharField, Field, Select
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberFormFieldMixin
from localflavor.generic.checksums import luhn

phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
Expand Down Expand Up @@ -45,31 +43,6 @@ def clean(self, value):
return "%s %s" % (m.group(1), m.group(2))


class CAPhoneNumberField(Field, DeprecatedPhoneNumberFormFieldMixin):
"""
Canadian phone number form field.
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

default_error_messages = {
'invalid': _('Phone numbers must be in XXX-XXX-XXXX format.'),
}

def clean(self, value):
super(CAPhoneNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = re.sub('(\(|\)|\s+)', '', force_text(value))
m = phone_digits_re.search(value)
if m:
return '%s-%s-%s' % (m.group(1), m.group(2), m.group(3))
raise ValidationError(self.error_messages['invalid'])


class CAProvinceField(Field):
"""
A form field that validates its input is a Canadian province name or abbreviation.
Expand Down
32 changes: 0 additions & 32 deletions localflavor/ch/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
from django.core.validators import EMPTY_VALUES, RegexValidator
from django.forms import ValidationError
from django.forms.fields import CharField, Field, RegexField, Select
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _

from localflavor.deprecation import DeprecatedPhoneNumberFormFieldMixin

from ..generic import validators
from .ch_states import STATE_CHOICES

Expand Down Expand Up @@ -40,35 +37,6 @@ def __init__(self, *args, **kwargs):
super(CHZipCodeField, self).__init__(zip_re, *args, **kwargs)


class CHPhoneNumberField(Field, DeprecatedPhoneNumberFormFieldMixin):
"""
Validate local Swiss phone number (not international ones).
The correct format is '0XX XXX XX XX'.
'0XX.XXX.XX.XX' and '0XXXXXXXXX' validate but are corrected to
'0XX XXX XX XX'.
.. deprecated:: 1.4
Use the django-phonenumber-field_ library instead.
.. _django-phonenumber-field: https://github.com/stefanfoulis/django-phonenumber-field
"""

default_error_messages = {
'invalid': _('Phone numbers must be in 0XX XXX XX XX format.'),
}

def clean(self, value):
super(CHPhoneNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = re.sub('(\.|\s|/|-)', '', force_text(value))
m = phone_digits_re.search(value)
if m:
return '%s %s %s %s' % (value[0:3], value[3:6], value[6:8], value[8:10])
raise ValidationError(self.error_messages['invalid'])


class CHStateSelect(Select):
"""A Select widget that uses a list of CH states as its choices."""

Expand Down
Loading

0 comments on commit dc6702d

Please sign in to comment.