Skip to content

Commit

Permalink
Fixed #15623 -- Corrected province codes for Canadian localflavor. Th…
Browse files Browse the repository at this point in the history
…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
freakboy3742 committed Mar 17, 2011
1 parent c2ae6b2 commit 1af3342
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
22 changes: 15 additions & 7 deletions django/contrib/localflavor/ca/ca_provinces.py
Expand Up @@ -8,21 +8,26 @@
This exists in this standalone file so that it's only imported into memory This exists in this standalone file so that it's only imported into memory
when explicitly needed. 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 = ( PROVINCE_CHOICES = (
('AB', 'Alberta'), ('AB', 'Alberta'),
('BC', 'British Columbia'), ('BC', 'British Columbia'),
('MB', 'Manitoba'), ('MB', 'Manitoba'),
('NB', 'New Brunswick'), ('NB', 'New Brunswick'),
('NF', 'Newfoundland and Labrador'), ('NL', 'Newfoundland and Labrador'),
('NT', 'Northwest Territories'), ('NT', 'Northwest Territories'),
('NS', 'Nova Scotia'), ('NS', 'Nova Scotia'),
('NU', 'Nunavut'), ('NU', 'Nunavut'),
('ON', 'Ontario'), ('ON', 'Ontario'),
('PE', 'Prince Edward Island'), ('PE', 'Prince Edward Island'),
('QC', 'Quebec'), ('QC', 'Quebec'),
('SK', 'Saskatchewan'), ('SK', 'Saskatchewan'),
('YK', 'Yukon') ('YT', 'Yukon')
) )


PROVINCES_NORMALIZED = { PROVINCES_NORMALIZED = {
Expand All @@ -35,9 +40,10 @@
'manitoba': 'MB', 'manitoba': 'MB',
'nb': 'NB', 'nb': 'NB',
'new brunswick': 'NB', 'new brunswick': 'NB',
'nf': 'NF', 'nf': 'NL',
'newfoundland': 'NF', 'nl': 'NL',
'newfoundland and labrador': 'NF', 'newfoundland': 'NL',
'newfoundland and labrador': 'NL',
'nt': 'NT', 'nt': 'NT',
'northwest territories': 'NT', 'northwest territories': 'NT',
'ns': 'NS', 'ns': 'NS',
Expand All @@ -54,6 +60,8 @@
'quebec': 'QC', 'quebec': 'QC',
'sk': 'SK', 'sk': 'SK',
'saskatchewan': 'SK', 'saskatchewan': 'SK',
'yk': 'YK', 'yk': 'YT',
'yukon': 'YK', 'yt': 'YT',
'yukon': 'YT',
'yukon territory': 'YT',
} }
5 changes: 5 additions & 0 deletions docs/releases/1.3.txt
Expand Up @@ -475,6 +475,11 @@ local flavors:
has been removed from the province list in favor of the new has been removed from the province list in favor of the new
official designation "Aceh (ACE)". 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 FormSet updates
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~


Expand Down
17 changes: 15 additions & 2 deletions tests/regressiontests/forms/localflavor/ca.py
@@ -1,3 +1,5 @@
import warnings

from django.contrib.localflavor.ca.forms import (CAPostalCodeField, from django.contrib.localflavor.ca.forms import (CAPostalCodeField,
CAPhoneNumberField, CAProvinceField, CAProvinceSelect, CAPhoneNumberField, CAProvinceField, CAProvinceSelect,
CASocialInsuranceNumberField) CASocialInsuranceNumberField)
Expand All @@ -6,22 +8,33 @@




class CALocalFlavorTests(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): def test_CAProvinceSelect(self):
f = CAProvinceSelect() f = CAProvinceSelect()
out = u'''<select name="province"> out = u'''<select name="province">
<option value="AB" selected="selected">Alberta</option> <option value="AB" selected="selected">Alberta</option>
<option value="BC">British Columbia</option> <option value="BC">British Columbia</option>
<option value="MB">Manitoba</option> <option value="MB">Manitoba</option>
<option value="NB">New Brunswick</option> <option value="NB">New Brunswick</option>
<option value="NF">Newfoundland and Labrador</option> <option value="NL">Newfoundland and Labrador</option>
<option value="NT">Northwest Territories</option> <option value="NT">Northwest Territories</option>
<option value="NS">Nova Scotia</option> <option value="NS">Nova Scotia</option>
<option value="NU">Nunavut</option> <option value="NU">Nunavut</option>
<option value="ON">Ontario</option> <option value="ON">Ontario</option>
<option value="PE">Prince Edward Island</option> <option value="PE">Prince Edward Island</option>
<option value="QC">Quebec</option> <option value="QC">Quebec</option>
<option value="SK">Saskatchewan</option> <option value="SK">Saskatchewan</option>
<option value="YK">Yukon</option> <option value="YT">Yukon</option>
</select>''' </select>'''
self.assertEqual(f.render('province', 'AB'), out) self.assertEqual(f.render('province', 'AB'), out)


Expand Down

0 comments on commit 1af3342

Please sign in to comment.