Skip to content

Commit

Permalink
fixed bug #464 where state choices was not working correctly with a c…
Browse files Browse the repository at this point in the history
…ountry code other than CA or US
  • Loading branch information
jsayles committed Jan 5, 2022
1 parent 8cef0bc commit c41c8ef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions member/static/css/member.css
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,11 @@ select#id_state {
box-sizing: border-box;
}

input#id_state {
padding-left: 1em;
width: 4em;
}

textarea#id_bio {
background-color: white;
height: 100px;
Expand Down
32 changes: 24 additions & 8 deletions nadine/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,28 @@


US_STATES = [
'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA',
'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME',
'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM',
'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX',
'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY',
('AL', 'Alabama'), ('Alaska', 'AK'), ('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'),
]

CA_PROVINCES = [
'AB', 'BC', 'MB', 'NB', 'NL', 'NT', 'NS',
'NU', 'ON', 'PE', 'QC', 'SK', 'YT'
('AB', 'Alberta'), ('BC', 'British Columbia'), ('MB', 'Manitoba'),
('NB', 'New Brunswick'), ('NL', 'Newfoundland and Labrador'),
('NT', 'Northwest Territories'), ('NS', 'Nova Scotia'), ('NU', 'Nunavut'),
('ON', 'Ontario'), ('PE', 'Prince Edward Island'), ('QC', 'Quebec'),
('SK', 'Saskatchewan'), ('YT', 'Yukon')
]

class DateRangeForm(forms.Form):
Expand Down Expand Up @@ -360,7 +372,11 @@ class EditProfileForm(forms.Form):
address1 = forms.CharField(max_length=100, required=False)
address2 = forms.CharField(max_length=100, required=False)
city = forms.CharField(max_length=100, required=False)
state = forms.ChoiceField(widget=forms.Select(attrs={'class': 'browser-default'}), choices=get_state_choices, required=False)
state_choices = get_state_choices()
if state_choices:
state = forms.ChoiceField(widget=forms.Select(attrs={'class': 'browser-default'}), choices=get_state_choices, required=False)
else:
state = forms.CharField(max_length=2, required=False)
zipcode = forms.CharField(max_length=16, required=False)
phone = forms.CharField(max_length=20, required=False)
phone2 = forms.CharField(max_length=20, required=False)
Expand Down

0 comments on commit c41c8ef

Please sign in to comment.