-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non-US plates, prepare to drop localflavor
We also narrow the set of license plate "states" down to just the 50 states and DC. While one should support American Samoa, and US military plates in the *general* case, they should realistically never come up when we're recording the license plates of cars that are being used to drive to New Hampshire from Boston. Indeed, of the many thousands of cars we have in the system already, *all* fall under the 50 states or Canada. We have 42 states represented, including DC. States that are missing: - Arkansas - Iowa - Mississippi - Nebraska - North Dakota - South Dakota - West Virginia - Wyoming To truly drop `localflavor`, we'll need to squash migrations again.
- Loading branch information
Showing
4 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
Provide a *simple* enumeration of US states without third-party deps. | ||
We used to rely on `localflavor` for this, but given that plates are | ||
the *only* use for this enum, it's easy/simple to just enumerate. | ||
""" | ||
from typing import Final | ||
|
||
US_STATES: Final[tuple[tuple[str, str], ...]] = ( | ||
('AL', 'Alabama'), | ||
('AK', 'Alaska'), | ||
('AZ', 'Arizona'), | ||
('AR', 'Arkansas'), | ||
('CA', 'California'), | ||
('CO', 'Colorado'), | ||
('CT', 'Connecticut'), | ||
('DE', 'Delaware'), | ||
('DC', 'District of Columbia'), | ||
('FL', 'Florida'), | ||
('GA', 'Georgia'), | ||
('HI', 'Hawaii'), | ||
('ID', 'Idaho'), | ||
('IL', 'Illinois'), | ||
('IN', 'Indiana'), | ||
('IA', 'Iowa'), | ||
('KS', 'Kansas'), | ||
('KY', 'Kentucky'), | ||
('LA', 'Louisiana'), | ||
('ME', 'Maine'), | ||
('MD', 'Maryland'), | ||
('MA', 'Massachusetts'), | ||
('MI', 'Michigan'), | ||
('MN', 'Minnesota'), | ||
('MS', 'Mississippi'), | ||
('MO', 'Missouri'), | ||
('MT', 'Montana'), | ||
('NE', 'Nebraska'), | ||
('NV', 'Nevada'), | ||
('NH', 'New Hampshire'), | ||
('NJ', 'New Jersey'), | ||
('NM', 'New Mexico'), | ||
('NY', 'New York'), | ||
('NC', 'North Carolina'), | ||
('ND', 'North Dakota'), | ||
('OH', 'Ohio'), | ||
('OK', 'Oklahoma'), | ||
('OR', 'Oregon'), | ||
('PA', 'Pennsylvania'), | ||
('RI', 'Rhode Island'), | ||
('SC', 'South Carolina'), | ||
('SD', 'South Dakota'), | ||
('TN', 'Tennessee'), | ||
('TX', 'Texas'), | ||
('UT', 'Utah'), | ||
('VT', 'Vermont'), | ||
('VA', 'Virginia'), | ||
('WA', 'Washington'), | ||
('WV', 'West Virginia'), | ||
('WI', 'Wisconsin'), | ||
('WY', 'Wyoming'), | ||
) | ||
|
||
|
||
CAR_STATE_CHOICES: Final[tuple[tuple[str, str], ...]] = ( | ||
*US_STATES, | ||
# License plates are *only* used for search & rescue | ||
# So long as the plate number is correct, we needn't be more specific. | ||
# In nine years, we've only seen one Canadian license plate requested. | ||
('XX', 'Other (Canada, Mexico, etc.)'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Generated by Django 3.2.21 on 2023-10-02 13:42 | ||
|
||
import django.core.validators | ||
import django.db.models.manager | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('ws', '0055_discount_url_non_null'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='car', | ||
name='state', | ||
field=models.CharField( | ||
choices=[ | ||
('AL', 'Alabama'), | ||
('AK', 'Alaska'), | ||
('AZ', 'Arizona'), | ||
('AR', 'Arkansas'), | ||
('CA', 'California'), | ||
('CO', 'Colorado'), | ||
('CT', 'Connecticut'), | ||
('DE', 'Delaware'), | ||
('DC', 'District of Columbia'), | ||
('FL', 'Florida'), | ||
('GA', 'Georgia'), | ||
('HI', 'Hawaii'), | ||
('ID', 'Idaho'), | ||
('IL', 'Illinois'), | ||
('IN', 'Indiana'), | ||
('IA', 'Iowa'), | ||
('KS', 'Kansas'), | ||
('KY', 'Kentucky'), | ||
('LA', 'Louisiana'), | ||
('ME', 'Maine'), | ||
('MD', 'Maryland'), | ||
('MA', 'Massachusetts'), | ||
('MI', 'Michigan'), | ||
('MN', 'Minnesota'), | ||
('MS', 'Mississippi'), | ||
('MO', 'Missouri'), | ||
('MT', 'Montana'), | ||
('NE', 'Nebraska'), | ||
('NV', 'Nevada'), | ||
('NH', 'New Hampshire'), | ||
('NJ', 'New Jersey'), | ||
('NM', 'New Mexico'), | ||
('NY', 'New York'), | ||
('NC', 'North Carolina'), | ||
('ND', 'North Dakota'), | ||
('OH', 'Ohio'), | ||
('OK', 'Oklahoma'), | ||
('OR', 'Oregon'), | ||
('PA', 'Pennsylvania'), | ||
('RI', 'Rhode Island'), | ||
('SC', 'South Carolina'), | ||
('SD', 'South Dakota'), | ||
('TN', 'Tennessee'), | ||
('TX', 'Texas'), | ||
('UT', 'Utah'), | ||
('VT', 'Vermont'), | ||
('VA', 'Virginia'), | ||
('WA', 'Washington'), | ||
('WV', 'West Virginia'), | ||
('WI', 'Wisconsin'), | ||
('WY', 'Wyoming'), | ||
('XX', 'Other (Canada, Mexico, etc.)'), | ||
], | ||
max_length=2, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name='car', | ||
name='year', | ||
field=models.PositiveIntegerField( | ||
validators=[ | ||
django.core.validators.MaxValueValidator(2025), | ||
django.core.validators.MinValueValidator(1903), | ||
] | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters