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

Removed deprecated code. #321

Merged
merged 2 commits into from
Dec 11, 2017
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
51 changes: 50 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,54 @@ 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 all deprecated classes, functions and associated data / regular expressions.
These are the classes and functions that have been removed
(`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`
- `hr.forms.HRPhoneNumberPrefixSelect`
- `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.

2 changes: 0 additions & 2 deletions docs/localflavor/hr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ Data
.. autodata:: localflavor.hr.hr_choices.HR_COUNTY_CHOICES

.. autodata:: localflavor.hr.hr_choices.HR_LICENSE_PLATE_PREFIX_CHOICES

.. autodata:: localflavor.hr.hr_choices.HR_PHONE_NUMBER_PREFIX_CHOICES
36 changes: 0 additions & 36 deletions localflavor/au/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@

from __future__ import unicode_literals

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

PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')


class AUPostCodeField(RegexField):
"""
Expand All @@ -33,34 +25,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
41 changes: 0 additions & 41 deletions localflavor/br/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
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})$')
cpf_digits_re = re.compile(r'^(\d{3})\.(\d{3})\.(\d{3})-(\d{2})$')
cnpj_digits_re = re.compile(
r'^(\d{2})[.-]?(\d{3})[.-]?(\d{3})/(\d{4})-(\d{2})$'
Expand All @@ -37,34 +33,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 +71,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
28 changes: 0 additions & 28 deletions localflavor/ca/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
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})$')
sin_re = re.compile(r"^(\d{3})-(\d{3})-(\d{3})$")


Expand Down Expand Up @@ -45,31 +42,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
Loading