Opened 9 years ago

Closed 9 years ago

#3988 closed (fixed)

Add Canadian (.ca) localflavor

Reported by: pi Owned by: ttarabula
Component: contrib.localflavor Version: master
Severity: Keywords: localflavor, ca
Cc: cbrand@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Patch to add a module to django.contrib.localflavor for Canada: CAPostalCodeField, CASocialInsuranceNumberField, CAProvinceField

Attachments (4)

patch.diff (2.6 KB) - added by pi 9 years ago.
Addition of .ca localflavor code
patch.2.diff (7.2 KB) - added by ttarabula 9 years ago.
patch.3.diff (7.2 KB) - added by ttarabula 9 years ago.
patch.4.diff (13.3 KB) - added by ttarabula 9 years ago.
Forgot to do an svn add before the svn diff

Download all attachments as: .zip

Change History (15)

comment:1 Changed 9 years ago by pi

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Canadian postal code re pattern:

'^[A-Z]\d[A-Z] \d[A-Z]\d$'

Note: The RE is valid after normalizing the case to upper case and forcing a single space character between character groups).

comment:2 Changed 9 years ago by Simon G. <dev@…>

Can you add a patch for this? i.e. add a new dir. in django.contrib.localflavor for ca and plug this into a "forms.py" file? - see one of the others for examples (e.g. AUPostCodeField in au/forms.py would be close)

Changed 9 years ago by pi

Attachment: patch.diff added

Addition of .ca localflavor code

comment:3 Changed 9 years ago by pi

Has patch: set
$ svn stat
A      ca
A      ca/ca_provinces.py
A      ca/__init__.py
A      ca/forms.py

See submitted patch for details.

comment:4 Changed 9 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:5 Changed 9 years ago by Malcolm Tredinnick

Needs tests: set
Triage Stage: Ready for checkinAccepted

Needs tests.

comment:6 Changed 9 years ago by cbrand@…

Cc: cbrand@… added

I think the regex used for postal codes is a little too generous.
Here's what I'm using in my code :

'[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d'

I don't think this is where I got it from, but it does seem to match :
http://www.forta.com/blog/index.cfm?mode=entry&entry=A61BA033-3048-80A9-EFF8935E41AB9FE2

comment:7 Changed 9 years ago by ttarabula

Owner: changed from nobody to anonymous
Status: newassigned

comment:8 Changed 9 years ago by ttarabula

Owner: changed from anonymous to ttarabula
Status: assignednew

Changed 9 years ago by ttarabula

Attachment: patch.2.diff added

comment:9 Changed 9 years ago by ttarabula

Addition of tests and modifications to .ca localflavor

Changed terminology "PostCode" to "PostalCode" to stay consistent with other localflavors
Modified CAPostalCodeField regex as per cbrand's advice
Modified CAPhoneNumberField to match USPhoneNumberField
Added CASocialInsuranceNumberField
Added CAProvinceField
Added tests for CAPostalCodeField, CAPhoneNumberField, CAProvinceField, CAProvinceSelect, CASocialInsuranceNumberField

Changed 9 years ago by ttarabula

Attachment: patch.3.diff added

Changed 9 years ago by ttarabula

Attachment: patch.4.diff added

Forgot to do an svn add before the svn diff

comment:10 Changed 9 years ago by Brian Rosner

Triage Stage: AcceptedReady for checkin

The patch looks good. Let a core dev look at it and get it in!

comment:11 Changed 9 years ago by Jacob

Resolution: fixed
Status: newclosed

(In [6202]) Fixed #3988: added a localflavor for our friends to the north (i.e. Canada). THanks, Tyler Tarabula.

Note: See TracTickets for help on using tickets.
Back to Top