caljer1 / auto-repair-shop

Automatically exported from code.google.com/p/auto-repair-shop
0 stars 0 forks source link

Change in validation isState #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. In Customer panel
2. Enter a state in lower case or combination upper and lower case (i.e. ca or 
Ca)

What is the expected output? What do you see instead?
Correct entry.
Validation error Invalid State

I suggest the following change [[ if s.upper() in states: ]] in code fragment 
below starting line 74:

def isState(s):
    #states, DX, possesions, territories and military bases
    states =  ("WA", "VA", "DE", "DC", "WI", "WV", "HI", "AE", "FL", "FM", "WY", "NH", "NJ", "NM", "TX", 
"LA", "NC", "ND", "NE", "TN", "NY", "PA", "CA", "NV", "AA", "PW", "GU", "CO", 
"VI", "AK", "AL", "AP", 
"AS", "AR", "VT", "IL", "GA", "IN", "IA", "OK", "AZ", "ID", "CT", "ME", "MD", 
"MA", "OH", "UT", "MO", 
"MN", "MI", "MH", "RI", "KS", "MT", "MP", "MS", "PR", "SC", "KY", "OR", "SD")
    if s in states:
       return (True,"")
    return (False,"Illegal State Name")

Original issue reported on code.google.com by jerome.c...@gmail.com on 13 Jun 2009 at 12:56

GoogleCodeExporter commented 9 years ago
I did not uppershift because I wanted the  value to be saved in a canonical form
so that CA and Ca records would not be detected as distinct. 
If uppershift compare was implemented, the db state validator routine should 
upshift the result so that the field will be in the canonical uppercase form.

Original comment by Les.Faby.78@gmail.com on 13 Jun 2009 at 2:08

GoogleCodeExporter commented 9 years ago
The ideal solution would be to provide this list to the View and have the view
produce a drop down list with "CA" as the default value.  This way the error 
cannot
occur and the value will always be in canonical form.  Short of that, let's just
convert it to upper case in the Customer object before saving to the data store.

Jerome, any thoughts on how difficult generating the drop down list might be?

Original comment by bd.gai...@gmail.com on 13 Jun 2009 at 3:28

GoogleCodeExporter commented 9 years ago
I will look into it. In WorkorderSubview I created a list of dictionary with 
value:name and iterated in the template. 
Another way will be to put the list of values in the template with a test for 
each value to check which one is 
selected.
This issue is not really critical IMO
~ j

Original comment by jerome.c...@gmail.com on 13 Jun 2009 at 9:15

GoogleCodeExporter commented 9 years ago
Drop-down menu implemented in work order subview. Case closed.

Original comment by jerome.c...@gmail.com on 17 Jun 2009 at 7:53