mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-13 22:00:27 +00:00
Merge pull request #90 from chekoopa/rename-fix
Fix redirect after renaming
This commit is contained in:
commit
02b54b5c04
@ -119,17 +119,26 @@ var handlerDeleteConfirm = factoryHandlerConfirmer(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
var handlerRenameConfirm = factoryHandlerConfirmer(
|
// handlerRenameConfirm should redirect to the new hypha, thus it's out of factory
|
||||||
"rename-confirm",
|
func handlerRenameConfirm(w http.ResponseWriter, rq *http.Request) {
|
||||||
func(oldHypha *hyphae.Hypha, u *user.User, rq *http.Request) (*history.HistoryOp, string) {
|
util.PrepareRq(rq)
|
||||||
var (
|
var (
|
||||||
|
u = user.FromRequest(rq)
|
||||||
|
hyphaName = util.HyphaNameFromRq(rq, "rename-confirm")
|
||||||
|
oldHypha = hyphae.ByName(hyphaName)
|
||||||
newName = util.CanonicalName(rq.PostFormValue("new-name"))
|
newName = util.CanonicalName(rq.PostFormValue("new-name"))
|
||||||
recursive = rq.PostFormValue("recursive") == "true"
|
|
||||||
newHypha = hyphae.ByName(newName)
|
newHypha = hyphae.ByName(newName)
|
||||||
|
recursive = rq.PostFormValue("recursive") == "true"
|
||||||
)
|
)
|
||||||
return shroom.RenameHypha(oldHypha, newHypha, recursive, u)
|
hop, errtitle := shroom.RenameHypha(oldHypha, newHypha, recursive, u)
|
||||||
},
|
if hop.HasErrors() {
|
||||||
)
|
httpErr(w, http.StatusInternalServerError, hyphaName,
|
||||||
|
errtitle,
|
||||||
|
hop.FirstErrorText())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.Redirect(w, rq, "/hypha/"+newName, http.StatusSeeOther)
|
||||||
|
}
|
||||||
|
|
||||||
// handlerEdit shows the edit form. It doesn't edit anything actually.
|
// handlerEdit shows the edit form. It doesn't edit anything actually.
|
||||||
func handlerEdit(w http.ResponseWriter, rq *http.Request) {
|
func handlerEdit(w http.ResponseWriter, rq *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user