Ticket #10456: calocal.diff
File calocal.diff, 5.1 KB (added by , 16 years ago) |
---|
-
django/contrib/localflavor/ca/ca_provinces.py
1 # -*- coding: utf-8 -*- 1 2 """ 2 3 An alphabetical list of provinces and territories for use as `choices` 3 4 in a formfield., and a mapping of province misspellings/abbreviations to … … 3 4 normalized abbreviations 4 5 5 Source: http://www.canada .gc.ca/othergov/prov_e.html6 Source: http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp#1380608 6 7 7 8 This exists in this standalone file so that it's only imported into memory … … 14 15 ('BC', 'British Columbia'), 15 16 ('MB', 'Manitoba'), 16 17 ('NB', 'New Brunswick'), 17 ('N F', 'Newfoundland and Labrador'),18 ('NL', 'Newfoundland and Labrador'), 18 19 ('NT', 'Northwest Territories'), 19 20 ('NS', 'Nova Scotia'), 20 21 ('NU', 'Nunavut'), … … 22 23 ('PE', 'Prince Edward Island'), 23 24 ('QC', 'Quebec'), 24 25 ('SK', 'Saskatchewan'), 25 ('Y K', 'Yukon')26 ('YT', 'Yukon') 26 27 ) 27 28 28 29 PROVINCES_NORMALIZED = { 29 30 'ab': 'AB', 31 'alta': 'AB', 32 'alta.': 'AB', 30 33 'alberta': 'AB', 31 34 'bc': 'BC', 32 35 'b.c.': 'BC', 33 36 'british columbia': 'BC', 37 'colombie-britannique': 'BC', 38 'colombie britannique': 'BC', 39 'cb': 'BC', 40 'c-b': 'BC', 34 41 'mb': 'MB', 35 42 'manitoba': 'MB', 36 43 'nb': 'NB', 37 44 'new brunswick': 'NB', 38 'nf': 'NF', 39 'newfoundland': 'NF', 40 'newfoundland and labrador': 'NF', 45 'nouveau-brunswick': 'NB', 46 'nouveau brunswick': 'NB', 47 'nf': 'NL', 48 'nl': 'NL', 49 'newfoundland': 'NL', 50 'newfoundland and labrador': 'NL', 51 'nfld': 'NL', 52 'nfld.': 'NL', 53 'terre-neuve-et-labrador': 'NL', 54 'terre-neuve et labrador': 'NL', 55 'terre-neuve': 'NL', 41 56 'nt': 'NT', 42 57 'northwest territories': 'NT', 58 'territoires du nord-ouest': 'NT', 43 59 'ns': 'NS', 44 60 'nova scotia': 'NS', 61 'nouvelle-écosse': 'NS', 62 'nouvelle-Écosse': 'NS', 63 'nouvelle écosse': 'NS', 64 'nouvelle Écosse': 'NS', 65 'nouvelle-ecosse': 'NS', 66 'nouvelle ecosse': 'NS', 45 67 'nu': 'NU', 46 68 'nunavut': 'NU', 47 69 'on': 'ON', … … 50 72 'pei': 'PE', 51 73 'p.e.i.': 'PE', 52 74 'prince edward island': 'PE', 75 'île du prince édouard': 'PE', 76 'Île du prince Édouard': 'PE', 77 'ile du prince edouard': 'PE', 78 'île-du-prince-édouard': 'PE', 79 'Île-du-prince-Édouard': 'PE', 80 'ile-du-prince-edouard': 'PE', 81 'î.p.e.': 'PE', 82 'i.p.e.': 'PE', 53 83 'qc': 'QC', 84 'qu': 'QC', 85 'pq': 'QC', 86 'que': 'QC', 87 'que.': 'QC', 54 88 'quebec': 'QC', 89 'québec': 'QC', 90 'quÉbec': 'QC', 55 91 'sk': 'SK', 56 92 'saskatchewan': 'SK', 57 'yk': 'YK', 58 'yukon': 'YK', 59 } 60 No newline at end of file 93 'sask': 'SK', 94 'sask.': 'SK', 95 'yk': 'YT', 96 'yt': 'YT', 97 'yukon': 'YT', 98 'yukon territory': 'YT', 99 } -
django/contrib/localflavor/ca/forms.py
20 20 def __init__(self, *args, **kwargs): 21 21 super(CAPostalCodeField, self).__init__(r'^[ABCEGHJKLMNPRSTVXYZ]\d[A-Z] \d[A-Z]\d$', 22 22 max_length=None, min_length=None, *args, **kwargs) 23 24 def clean(self, value): 25 if value: 26 value = str(value).upper() 27 if len(value) == 6: # Add a space if there isn't one 28 value = value[:3] + ' ' + value[3:] 29 return super(CAPostalCodeField, self).clean(value) 23 30 24 31 class CAPhoneNumberField(Field): 25 32 """Canadian phone number field.""" -
tests/regressiontests/forms/localflavor/ca.py
37 37 >>> f.clean('T2S 2H7') 38 38 u'T2S 2H7' 39 39 >>> f.clean('T2S2H7') 40 Traceback (most recent call last): 41 ... 42 ValidationError: [u'Enter a postal code in the format XXX XXX.'] 40 u'T2S 2H7' 41 >>> f.clean('t2s2h7') 42 u'T2S 2H7' 43 43 >>> f.clean('T2S 2H') 44 44 Traceback (most recent call last): 45 45 ... … … 171 171 u'BC' 172 172 >>> f.clean('nova scotia') 173 173 u'NS' 174 >>> f.clean('nf') 175 u'NL' 176 >>> f.clean('québec ') 177 u'QC' 174 178 >>> f.clean(' manitoba ') 175 179 u'MB' 176 180 >>> f.clean('T2S 2H7') … … 194 198 <option value="BC">British Columbia</option> 195 199 <option value="MB">Manitoba</option> 196 200 <option value="NB">New Brunswick</option> 197 <option value="N F">Newfoundland and Labrador</option>201 <option value="NL">Newfoundland and Labrador</option> 198 202 <option value="NT">Northwest Territories</option> 199 203 <option value="NS">Nova Scotia</option> 200 204 <option value="NU">Nunavut</option> … … 202 206 <option value="PE">Prince Edward Island</option> 203 207 <option value="QC">Quebec</option> 204 208 <option value="SK">Saskatchewan</option> 205 <option value="Y K">Yukon</option>209 <option value="YT">Yukon</option> 206 210 </select> 207 211 208 212 # CASocialInsuranceNumberField #################################################