Clean unused categories on every action with posts in mindflow.
This commit is contained in:
parent
2ef1b98fdb
commit
51b69e87cf
@ -250,6 +250,10 @@ func (h *MindflowApiHandlers) New(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := h.db.DeleteUnusedCategories(); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
http.Redirect(w, r, "/mindflow/admin", http.StatusMovedPermanently)
|
http.Redirect(w, r, "/mindflow/admin", http.StatusMovedPermanently)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,11 +309,20 @@ func (h *MindflowApiHandlers) Edit(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := h.db.DeleteUnusedCategories(); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MindflowApiHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
func (h *MindflowApiHandlers) Delete(w http.ResponseWriter, r *http.Request) {
|
||||||
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
||||||
if err := h.db.Delete(id); err != nil {
|
if err := h.db.Delete(id); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.db.DeleteUnusedCategories(); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user