From 1af33427cb4d6e4ec12c61b68d9da738754b429d Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 17 Mar 2011 00:59:30 +0000 Subject: [PATCH] Fixed #15623 -- Corrected province codes for Canadian localflavor. Thanks to shelldweller for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15864 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/localflavor/ca/ca_provinces.py | 22 +++++++++++++------ docs/releases/1.3.txt | 5 +++++ tests/regressiontests/forms/localflavor/ca.py | 17 ++++++++++++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/django/contrib/localflavor/ca/ca_provinces.py b/django/contrib/localflavor/ca/ca_provinces.py index 746716fd21..505d863f5e 100644 --- a/django/contrib/localflavor/ca/ca_provinces.py +++ b/django/contrib/localflavor/ca/ca_provinces.py @@ -8,13 +8,18 @@ Source: http://www.canada.gc.ca/othergov/prov_e.html This exists in this standalone file so that it's only imported into memory when explicitly needed. """ +import warnings +warnings.warn( + 'There have been recent changes to the CA localflavor. See the release notes for details', + RuntimeWarning +) PROVINCE_CHOICES = ( ('AB', 'Alberta'), ('BC', 'British Columbia'), ('MB', 'Manitoba'), ('NB', 'New Brunswick'), - ('NF', 'Newfoundland and Labrador'), + ('NL', 'Newfoundland and Labrador'), ('NT', 'Northwest Territories'), ('NS', 'Nova Scotia'), ('NU', 'Nunavut'), @@ -22,7 +27,7 @@ PROVINCE_CHOICES = ( ('PE', 'Prince Edward Island'), ('QC', 'Quebec'), ('SK', 'Saskatchewan'), - ('YK', 'Yukon') + ('YT', 'Yukon') ) PROVINCES_NORMALIZED = { @@ -35,9 +40,10 @@ PROVINCES_NORMALIZED = { 'manitoba': 'MB', 'nb': 'NB', 'new brunswick': 'NB', - 'nf': 'NF', - 'newfoundland': 'NF', - 'newfoundland and labrador': 'NF', + 'nf': 'NL', + 'nl': 'NL', + 'newfoundland': 'NL', + 'newfoundland and labrador': 'NL', 'nt': 'NT', 'northwest territories': 'NT', 'ns': 'NS', @@ -54,6 +60,8 @@ PROVINCES_NORMALIZED = { 'quebec': 'QC', 'sk': 'SK', 'saskatchewan': 'SK', - 'yk': 'YK', - 'yukon': 'YK', + 'yk': 'YT', + 'yt': 'YT', + 'yukon': 'YT', + 'yukon territory': 'YT', } \ No newline at end of file diff --git a/docs/releases/1.3.txt b/docs/releases/1.3.txt index 7d4dfaca64..8a9a209897 100644 --- a/docs/releases/1.3.txt +++ b/docs/releases/1.3.txt @@ -475,6 +475,11 @@ local flavors: has been removed from the province list in favor of the new official designation "Aceh (ACE)". + * Canada (ca) -- The province "Newfoundland and Labrador" has + had its province code updated to "NL", rather than the + older "NF". In addition, the Yukon Territory has had its + province code corrected to "YT", instead of "YK". + FormSet updates ~~~~~~~~~~~~~~~ diff --git a/tests/regressiontests/forms/localflavor/ca.py b/tests/regressiontests/forms/localflavor/ca.py index 575f41c8be..bd31a5ce46 100644 --- a/tests/regressiontests/forms/localflavor/ca.py +++ b/tests/regressiontests/forms/localflavor/ca.py @@ -1,3 +1,5 @@ +import warnings + from django.contrib.localflavor.ca.forms import (CAPostalCodeField, CAPhoneNumberField, CAProvinceField, CAProvinceSelect, CASocialInsuranceNumberField) @@ -6,6 +8,17 @@ from utils import LocalFlavorTestCase class CALocalFlavorTests(LocalFlavorTestCase): + def setUp(self): + self.save_warnings_state() + warnings.filterwarnings( + "ignore", + category=RuntimeWarning, + module='django.contrib.localflavor.ca.ca_provinces' + ) + + def tearDown(self): + self.restore_warnings_state() + def test_CAProvinceSelect(self): f = CAProvinceSelect() out = u'''''' self.assertEqual(f.render('province', 'AB'), out)