Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

9 digits phones for São Paulo/Brazil (Ticket #18536) #237

Closed
wants to merge 1 commit into from

2 participants

Sergio Oliveira Adrian Holovaty
Adrian Holovaty
Collaborator

Hey there -- django.contrib.localflavor is now deprecated, and we're not making any more changes to it. Could you reopen this pull request for the shiny new package django-localflavor-br? Here's the link: https://github.com/django/django-localflavor-br

Sorry we didn't get to this pull request before the deprecation. I hope it's not too much of a pain to migrate this to the new package.

Sergio Oliveira

Thanks @adrianholovaty! Actually I like the idea of having local flavors apart from the django core. It will give a lot more flexibility mainly on updates.

Currently we discuss a lot about localflavors-br on the django l10n mailing list. What would be the right place to discuss features that could be included in the new django-localflavor-br? Maybe django-dev?

Adrian Holovaty
Collaborator

@seocam Glad you like it -- the greater flexibility is exactly why we wanted to do it.

I don't think django-dev is the right place to discuss country-specific localflavors. I'd suggest django-l10n instead, or maybe setting up a separate mailing list for the BR localflavor if that's not too much of a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 29, 2012
  1. Sergio Oliveira
This page is out of date. Refresh to see the latest.
5 django/contrib/localflavor/br/forms.py
View
@@ -15,7 +15,7 @@
from django.utils.translation import ugettext_lazy as _
-phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$')
+phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4,5})[-\.]?(\d{4})$')
class BRZipCodeField(RegexField):
default_error_messages = {
@@ -28,7 +28,8 @@ def __init__(self, max_length=None, min_length=None, *args, **kwargs):
class BRPhoneNumberField(Field):
default_error_messages = {
- 'invalid': _('Phone numbers must be in XX-XXXX-XXXX format.'),
+ 'invalid': _(('Phone numbers must be in either of the following '
+ 'formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.')),
}
def clean(self, value):
16 tests/regressiontests/localflavor/br/tests.py
View
@@ -1,3 +1,4 @@
+# -*- encoding: utf8 -*-
from __future__ import unicode_literals
from django.contrib.localflavor.br.forms import (BRZipCodeField,
@@ -62,7 +63,8 @@ def test_BRCPFField(self):
self.assertFieldOutput(BRCPFField, valid, invalid)
def test_BRPhoneNumberField(self):
- # TODO: this doesn't test for any invalid inputs.
+ error_format = [('Phone numbers must be in either of the following '
+ 'formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.')]
valid = {
'41-3562-3464': '41-3562-3464',
'4135623464': '41-3562-3464',
@@ -70,10 +72,20 @@ def test_BRPhoneNumberField(self):
'41 3562 3464': '41-3562-3464',
'(41) 3562 3464': '41-3562-3464',
'41.3562.3464': '41-3562-3464',
+ '41.93562.3464': '41-93562-3464',
'41.3562-3464': '41-3562-3464',
' (41) 3562.3464': '41-3562-3464',
+ ' (41) 98765.3464': '41-98765-3464',
+ '(16) 91342-4325': '16-91342-4325',
+ }
+ invalid = {
+ '11-914-925': error_format,
+ '11-9144-43925': error_format,
+ '11-91342-94325': error_format,
+ '411-9134-9435': error_format,
+ '+55-41-3562-3464': error_format,
+ '41 3562–3464': error_format,
}
- invalid = {}
self.assertFieldOutput(BRPhoneNumberField, valid, invalid)
def test_BRStateSelect(self):
Something went wrong with that request. Please try again.