sklad: redirect to GET on successful DB changes
This commit is contained in:
parent
7d2ca09d1b
commit
04e66d7888
@ -115,12 +115,15 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
err = handleContainerPost(r)
|
if err = handleContainerPost(r); err == nil {
|
||||||
// FIXME: This is rather ugly. When removing, we want to keep
|
redirect := "container"
|
||||||
// the context id, in addition to the id being changed.
|
if shownId != "" {
|
||||||
// TODO: If there were no errors, redirect the user to GET,
|
redirect += "?id=" + url.QueryEscape(shownId)
|
||||||
// which is related to the previous comment.
|
}
|
||||||
// TODO: If there were errors, use the last data as a prefill.
|
http.Redirect(w, r, redirect, http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO: Use the last data as a prefill.
|
||||||
} else if r.Method != http.MethodGet {
|
} else if r.Method != http.MethodGet {
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
@ -194,7 +197,10 @@ func handleSeriesPost(r *http.Request) error {
|
|||||||
func handleSeries(w http.ResponseWriter, r *http.Request) {
|
func handleSeries(w http.ResponseWriter, r *http.Request) {
|
||||||
var err error
|
var err error
|
||||||
if r.Method == http.MethodPost {
|
if r.Method == http.MethodPost {
|
||||||
err = handleSeriesPost(r)
|
if err = handleSeriesPost(r); err == nil {
|
||||||
|
http.Redirect(w, r, "series", http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
}
|
||||||
// XXX: This is rather ugly.
|
// XXX: This is rather ugly.
|
||||||
r.Form = url.Values{}
|
r.Form = url.Values{}
|
||||||
} else if r.Method != http.MethodGet {
|
} else if r.Method != http.MethodGet {
|
||||||
|
Loading…
Reference in New Issue
Block a user