allow renaming shortnames

This commit is contained in:
Ted Unangst 2019-10-06 21:45:58 -04:00
parent 9ad6418c16
commit df94bdb4ed
3 changed files with 4 additions and 3 deletions

View File

@ -504,7 +504,7 @@ func cleanupdb(arg string) {
}
}
var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt
var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt
var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt
var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt
var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtWhatAbout *sql.Stmt
@ -529,7 +529,7 @@ func prepareStatements(db *sql.DB) {
stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name")
stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos) values (?, ?, ?, ?, ?)")
stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and flavor = ?")
stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?")
stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ? where honkerid = ? and userid = ?")
stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?")
stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'")

View File

@ -38,6 +38,7 @@ function expandstuff() {
<form action="/submithonker" method="POST">
<input type="hidden" name="CSRF" value="{{ $honkercsrf }}">
<input type="hidden" name="honkerid" value="{{ .ID }}">
<p>name: <input type="text" name="name" value="{{ .Name }}">
<p>combos: <input type="text" name="combos" value="{{ range .Combos }}{{ . }} {{end}}">
{{ if eq .Flavor "sub" }}
<p>unsub: <input type="text" name="goodbye" placeholder="press F" value="" autocomplete=off>

2
web.go
View File

@ -1226,7 +1226,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
return
}
combos = " " + strings.TrimSpace(combos) + " "
_, err := stmtUpdateCombos.Exec(combos, honkerid, u.UserID)
_, err := stmtUpdateHonker.Exec(name, combos, honkerid, u.UserID)
if err != nil {
log.Printf("update honker err: %s", err)
return