Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

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.

Adrian Holovaty adrianholovaty closed this October 15, 2012
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

@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.

Sergio Oliveira seocam referenced this pull request in django/django-localflavor-br October 25, 2012
Merged

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 28, 2012
Sergio Oliveira 9 digits phones for São Paulo/Brazil. ef5623a
This page is out of date. Refresh to see the latest.
5  django/contrib/localflavor/br/forms.py
@@ -15,7 +15,7 @@
15 15
 from django.utils.translation import ugettext_lazy as _
16 16
 
17 17
 
18  
-phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$')
  18
+phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4,5})[-\.]?(\d{4})$')
19 19
 
20 20
 class BRZipCodeField(RegexField):
21 21
     default_error_messages = {
@@ -28,7 +28,8 @@ def __init__(self, max_length=None, min_length=None, *args, **kwargs):
28 28
 
29 29
 class BRPhoneNumberField(Field):
30 30
     default_error_messages = {
31  
-        'invalid': _('Phone numbers must be in XX-XXXX-XXXX format.'),
  31
+        'invalid': _(('Phone numbers must be in either of the following '     
  32
+                         'formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.')),
32 33
     }
33 34
 
34 35
     def clean(self, value):
16  tests/regressiontests/localflavor/br/tests.py
... ...
@@ -1,3 +1,4 @@
  1
+# -*- encoding: utf8 -*-
1 2
 from __future__ import unicode_literals
2 3
 
3 4
 from django.contrib.localflavor.br.forms import (BRZipCodeField,
@@ -62,7 +63,8 @@ def test_BRCPFField(self):
62 63
         self.assertFieldOutput(BRCPFField, valid, invalid)
63 64
 
64 65
     def test_BRPhoneNumberField(self):
65  
-        # TODO: this doesn't test for any invalid inputs.
  66
+        error_format = [('Phone numbers must be in either of the following '
  67
+                         'formats: XX-XXXX-XXXX or XX-XXXXX-XXXX.')]
66 68
         valid = {
67 69
             '41-3562-3464': '41-3562-3464',
68 70
             '4135623464': '41-3562-3464',
@@ -70,10 +72,20 @@ def test_BRPhoneNumberField(self):
70 72
             '41 3562 3464': '41-3562-3464',
71 73
             '(41) 3562 3464': '41-3562-3464',
72 74
             '41.3562.3464': '41-3562-3464',
  75
+            '41.93562.3464': '41-93562-3464',
73 76
             '41.3562-3464': '41-3562-3464',
74 77
             ' (41) 3562.3464': '41-3562-3464',
  78
+            ' (41) 98765.3464': '41-98765-3464',
  79
+            '(16) 91342-4325': '16-91342-4325',
  80
+        }
  81
+        invalid = {
  82
+            '11-914-925': error_format,
  83
+            '11-9144-43925': error_format,
  84
+            '11-91342-94325': error_format,
  85
+            '411-9134-9435': error_format,
  86
+            '+55-41-3562-3464': error_format,
  87
+            '41 3562–3464': error_format,
75 88
         }
76  
-        invalid = {}
77 89
         self.assertFieldOutput(BRPhoneNumberField, valid, invalid)
78 90
 
79 91
     def test_BRStateSelect(self):
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.