Compare commits
2 Commits
4ad4bcf9e7
...
04e66d7888
Author | SHA1 | Date | |
---|---|---|---|
04e66d7888 | |||
7d2ca09d1b |
@ -107,14 +107,23 @@ func handleContainerPost(r *http.Request) error {
|
||||
}
|
||||
|
||||
func handleContainer(w http.ResponseWriter, r *http.Request) {
|
||||
// When deleting, do not try to show the deleted entry but the context.
|
||||
shownId := r.FormValue("context")
|
||||
if shownId == "" {
|
||||
shownId = r.FormValue("id")
|
||||
}
|
||||
|
||||
var err error
|
||||
if r.Method == http.MethodPost {
|
||||
err = handleContainerPost(r)
|
||||
// FIXME: This is rather ugly. When removing, we want to keep
|
||||
// the context id, in addition to the id being changed.
|
||||
// TODO: If there were no errors, redirect the user to GET,
|
||||
// which is related to the previous comment.
|
||||
// TODO: If there were errors, use the last data as a prefill.
|
||||
if err = handleContainerPost(r); err == nil {
|
||||
redirect := "container"
|
||||
if shownId != "" {
|
||||
redirect += "?id=" + url.QueryEscape(shownId)
|
||||
}
|
||||
http.Redirect(w, r, redirect, http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
// TODO: Use the last data as a prefill.
|
||||
} else if r.Method != http.MethodGet {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
@ -128,7 +137,7 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
|
||||
var container *Container
|
||||
children := indexChildren[""]
|
||||
|
||||
if c, ok := indexContainer[ContainerId(r.FormValue("id"))]; ok {
|
||||
if c, ok := indexContainer[ContainerId(shownId)]; ok {
|
||||
children = c.Children()
|
||||
container = c
|
||||
}
|
||||
@ -188,7 +197,10 @@ func handleSeriesPost(r *http.Request) error {
|
||||
func handleSeries(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
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.
|
||||
r.Form = url.Values{}
|
||||
} else if r.Method != http.MethodGet {
|
||||
|
Loading…
x
Reference in New Issue
Block a user