func profileUpdateHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { cdb := complaintdb.NewDB(ctx) r.ParseForm() lat, err := strconv.ParseFloat(r.FormValue("Lat"), 64) if err != nil { cdb.Errorf("profileUpdate:, parse lat '%s': %v", r.FormValue("Lat"), err) http.Error(w, err.Error(), http.StatusInternalServerError) return } long, err2 := strconv.ParseFloat(r.FormValue("Long"), 64) if err2 != nil { cdb.Errorf("profileUpdate:, parse long '%s': %v", r.FormValue("Long"), err) http.Error(w, err2.Error(), http.StatusInternalServerError) return } sesh, _ := GetUserSession(ctx) // Maybe make a call to fetch the elevation ?? // https://developers.google.com/maps/documentation/elevation/intro cp := types.ComplainerProfile{ EmailAddress: sesh.Email, CallerCode: r.FormValue("CallerCode"), FullName: strings.TrimSpace(r.FormValue("FullName")), Address: strings.TrimSpace(r.FormValue("AutoCompletingMagic")), StructuredAddress: types.PostalAddress{ Number: r.FormValue("AddrNumber"), Street: r.FormValue("AddrStreet"), City: r.FormValue("AddrCity"), State: r.FormValue("AddrState"), Zip: r.FormValue("AddrZip"), Country: r.FormValue("AddrCountry"), }, CcSfo: true, //FormValueCheckbox(r, "CcSfo"), DataSharing: FormValueTriValuedCheckbox(r, "DataSharing"), ThirdPartyComms: FormValueTriValuedCheckbox(r, "ThirdPartyComms"), Lat: lat, Long: long, ButtonId: []string{}, } // Preserve some values from the old profile if origProfile, err := cdb.GetProfileByEmailAddress(sesh.Email); err == nil { cp.ButtonId = origProfile.ButtonId } if err := cdb.PutProfile(cp); err != nil { cdb.Errorf("profileUpdate: cdb.Put: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } http.Redirect(w, r, "/", http.StatusFound) }