Opened 8 years ago

Closed 8 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 8 years ago.
Addition of .ca localflavor code
patch.2.diff (7.2 KB) - added by ttarabula 8 years ago.
patch.3.diff (7.2 KB) - added by ttarabula 8 years ago.
patch.4.diff (13.3 KB) - added by ttarabula 8 years ago.
Forgot to do an svn add before the svn diff

Download all attachments as: .zip

Change History (15)

comment:1 Changed 8 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 8 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 8 years ago by pi

Addition of .ca localflavor code

comment:3 Changed 8 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 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:5 Changed 8 years ago by mtredinnick

  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted

Needs tests.

comment:6 Changed 8 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 8 years ago by ttarabula

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:8 Changed 8 years ago by ttarabula

  • Owner changed from anonymous to ttarabula
  • Status changed from assigned to new

Changed 8 years ago by ttarabula

comment:9 Changed 8 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 8 years ago by ttarabula

Changed 8 years ago by ttarabula

Forgot to do an svn add before the svn diff

comment:10 Changed 8 years ago by brosner

  • Triage Stage changed from Accepted to Ready for checkin

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

comment:11 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(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