Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15623 -- Corrected province codes for Canadian localflavor. Th…

…anks to shelldweller for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15864 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1af33427cb4d6e4ec12c61b68d9da738754b429d 1 parent c2ae6b2
Russell Keith-Magee authored March 17, 2011
22  django/contrib/localflavor/ca/ca_provinces.py
@@ -8,13 +8,18 @@
8 8
 This exists in this standalone file so that it's only imported into memory 
9 9
 when explicitly needed. 
10 10
 """ 
  11
+import warnings
  12
+warnings.warn(
  13
+    'There have been recent changes to the CA localflavor. See the release notes for details',
  14
+    RuntimeWarning
  15
+)
11 16
 
12 17
 PROVINCE_CHOICES = ( 
13 18
     ('AB', 'Alberta'), 
14 19
     ('BC', 'British Columbia'), 
15 20
     ('MB', 'Manitoba'), 
16 21
     ('NB', 'New Brunswick'), 
17  
-    ('NF', 'Newfoundland and Labrador'), 
  22
+    ('NL', 'Newfoundland and Labrador'),
18 23
     ('NT', 'Northwest Territories'), 
19 24
     ('NS', 'Nova Scotia'), 
20 25
     ('NU', 'Nunavut'), 
@@ -22,7 +27,7 @@
22 27
     ('PE', 'Prince Edward Island'), 
23 28
     ('QC', 'Quebec'), 
24 29
     ('SK', 'Saskatchewan'), 
25  
-    ('YK', 'Yukon') 
  30
+    ('YT', 'Yukon')
26 31
 )
27 32
 
28 33
 PROVINCES_NORMALIZED = {
@@ -35,9 +40,10 @@
35 40
     'manitoba': 'MB',
36 41
     'nb': 'NB',
37 42
     'new brunswick': 'NB',
38  
-    'nf': 'NF',
39  
-    'newfoundland': 'NF',
40  
-    'newfoundland and labrador': 'NF',
  43
+    'nf': 'NL',
  44
+    'nl': 'NL',
  45
+    'newfoundland': 'NL',
  46
+    'newfoundland and labrador': 'NL',
41 47
     'nt': 'NT',
42 48
     'northwest territories': 'NT',
43 49
     'ns': 'NS',
@@ -54,6 +60,8 @@
54 60
     'quebec': 'QC',
55 61
     'sk': 'SK',
56 62
     'saskatchewan': 'SK',
57  
-    'yk': 'YK',
58  
-    'yukon': 'YK',
  63
+    'yk': 'YT',
  64
+    'yt': 'YT',
  65
+    'yukon': 'YT',
  66
+    'yukon territory': 'YT',
59 67
 }
5  docs/releases/1.3.txt
@@ -475,6 +475,11 @@ local flavors:
475 475
       has been removed from the province list in favor of the new
476 476
       official designation "Aceh (ACE)".
477 477
 
  478
+    * Canada (ca) -- The province "Newfoundland and Labrador" has
  479
+      had its province code updated to "NL", rather than the
  480
+      older "NF". In addition, the Yukon Territory has had its
  481
+      province code corrected to "YT", instead of "YK".
  482
+
478 483
 FormSet updates
479 484
 ~~~~~~~~~~~~~~~
480 485
 
17  tests/regressiontests/forms/localflavor/ca.py
... ...
@@ -1,3 +1,5 @@
  1
+import warnings
  2
+
1 3
 from django.contrib.localflavor.ca.forms import (CAPostalCodeField,
2 4
         CAPhoneNumberField, CAProvinceField, CAProvinceSelect,
3 5
         CASocialInsuranceNumberField)
@@ -6,6 +8,17 @@
6 8
 
7 9
 
8 10
 class CALocalFlavorTests(LocalFlavorTestCase):
  11
+    def setUp(self):
  12
+        self.save_warnings_state()
  13
+        warnings.filterwarnings(
  14
+            "ignore",
  15
+            category=RuntimeWarning,
  16
+            module='django.contrib.localflavor.ca.ca_provinces'
  17
+        )
  18
+
  19
+    def tearDown(self):
  20
+        self.restore_warnings_state()
  21
+
9 22
     def test_CAProvinceSelect(self):
10 23
         f = CAProvinceSelect()
11 24
         out = u'''<select name="province">
@@ -13,7 +26,7 @@ def test_CAProvinceSelect(self):
13 26
 <option value="BC">British Columbia</option>
14 27
 <option value="MB">Manitoba</option>
15 28
 <option value="NB">New Brunswick</option>
16  
-<option value="NF">Newfoundland and Labrador</option>
  29
+<option value="NL">Newfoundland and Labrador</option>
17 30
 <option value="NT">Northwest Territories</option>
18 31
 <option value="NS">Nova Scotia</option>
19 32
 <option value="NU">Nunavut</option>
@@ -21,7 +34,7 @@ def test_CAProvinceSelect(self):
21 34
 <option value="PE">Prince Edward Island</option>
22 35
 <option value="QC">Quebec</option>
23 36
 <option value="SK">Saskatchewan</option>
24  
-<option value="YK">Yukon</option>
  37
+<option value="YT">Yukon</option>
25 38
 </select>'''
26 39
         self.assertEqual(f.render('province', 'AB'), out)
27 40
 

0 notes on commit 1af3342

Please sign in to comment.
Something went wrong with that request. Please try again.