Code

Opened 6 years ago

Closed 4 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: UI/UX:

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 5 years ago.
us_states patch to add Armed Forces entries.
usps_fields.diff (15.0 KB) - added by dougvanhorn 5 years ago.
US Postal Codes patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by dougvanhorn

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to dougvanhorn
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Definitely a bug. I'll attach a patch.

Changed 5 years ago by dougvanhorn

us_states patch to add Armed Forces entries.

comment:2 Changed 5 years ago by dougvanhorn

  • Has patch set

comment:3 Changed 5 years ago by russellm

  • Resolution set to wontfix
  • Status changed from assigned to closed

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

comment:4 Changed 5 years ago by dougvanhorn

  • Resolution wontfix deleted
  • Status changed from closed to reopened

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 Changed 5 years ago by carljm

  • Resolution set to wontfix
  • Status changed from reopened to closed

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 Changed 5 years ago by ubernostrum

  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Accepted to Design decision needed

I actually did bring it up.

Back to DDN.

comment:7 Changed 5 years ago by dougvanhorn

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.

Changed 5 years ago by dougvanhorn

US Postal Codes patch

comment:8 Changed 5 years ago by dougvanhorn

  • Cc dougvanhorn@… added

comment:9 Changed 4 years ago by ubernostrum

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.