Opened 16 years ago

Closed 13 years ago

#9022 closed (fixed)

Allow US armed forces state codes for USStateField

Reported by: Daniel Pope <dan@…> Owned by: dougvanhorn
Component: contrib.localflavor Version: 1.0
Severity: Keywords:
Cc: dougvanhorn@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm not a Yank so I don't know how useful this is to you chaps over the pond. The official list of state codes supported by the US Postal Service was linked on thedailywtf.com and I checked to discover Django does not handle all of the codes:

http://www.usps.com/ncsc/lookups/abbreviations.html#states

Obviously this list runs contrary to #8425 but I thought this deserved a ticket in case you are discriminating against your boys in the Middle East, you UN-AMERICAN, COMMUNIST, CHEESE-EATING... er, wait. I think I'm getting my imported redneck epithets mixed up.

Attachments (2)

armed_forces.diff (1.8 KB ) - added by dougvanhorn 15 years ago.
us_states patch to add Armed Forces entries.
usps_fields.diff (15.0 KB ) - added by dougvanhorn 15 years ago.
US Postal Codes patch

Download all attachments as: .zip

Change History (11)

comment:1 by dougvanhorn, 15 years ago

Owner: changed from nobody to dougvanhorn
Status: newassigned
Triage Stage: UnreviewedAccepted

Definitely a bug. I'll attach a patch.

by dougvanhorn, 15 years ago

Attachment: armed_forces.diff added

us_states patch to add Armed Forces entries.

comment:2 by dougvanhorn, 15 years ago

Has patch: set

comment:3 by Russell Keith-Magee, 15 years ago

Resolution: wontfix
Status: assignedclosed

Based on Adrian's comment on #10308, marking wontfix.

comment:4 by dougvanhorn, 15 years ago

Resolution: wontfix
Status: closedreopened

I'm reopening this ticket because I don't think Adrian's reasoning is sound, based on the fact that there are non-US states in the us_states.py module, such as:

  • American Somoa
  • Guam
  • Northern Mariana Islands
  • Puerto Rico
  • Virgin Islands

I would also point to the USStateField documentation:

class USStateField(Field):
    """
    A form field that validates its input is a U.S. state name or abbreviation.
    It normalizes the input to the standard two-leter postal service
    abbreviation for the given state.
    """

Which, rather plainly, states that the intent of the field is to represent two-letter postal service abbreviations.

If we're to believe us_states.py should only represent the 50 states with a star on the flag, we need to patch the us_states.py module to remove the US territories listed above.

comment:5 by Carl Meyer, 15 years ago

Resolution: wontfix
Status: reopenedclosed

As documented in the contributing docs, do not reopen tickets marked wontfix by a core committer. If you have something new to add, bring it up on the django-developers mailing list.

comment:6 by James Bennett, 15 years ago

Resolution: wontfix
Status: closedreopened
Triage Stage: AcceptedDesign decision needed

I actually did bring it up.

Back to DDN.

comment:7 by dougvanhorn, 15 years ago

I'm adding a patch to this ticket that will add a USPSStateField to the US localflavor package.

The USPostalCodeField will provide a model field and form fields which will validate USPS Postal Codes per http://www.usps.com/ncsc/lookups/abbreviations.html.

The patch includes regression test updated for forms and serializers_regress (though I'm unsure of what the serializers_regress tests are testing).

./runtests.py passes with 914 tests.

I'm not sure this is the right design choice, but since there seems to be disagreement as to what constitutes a US State, I figured I'd add a field specifically for US Postal Codes.

I'm not sure what this would mean to the USStateField, which, right now, is neither US States nor Postal Codes.

by dougvanhorn, 15 years ago

Attachment: usps_fields.diff added

US Postal Codes patch

comment:8 by dougvanhorn, 15 years ago

Cc: dougvanhorn@… added

comment:9 by James Bennett, 13 years ago

Resolution: fixed
Status: reopenedclosed

(In [15029]) Refactor the choices for localflavor's USStateField, and add new US postal code support. Fixes #14937 and #9022, refs #10308 and #8425.

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