1
0

Moved category handlers to the end.

This commit is contained in:
Alexander Andreev 2023-05-22 23:40:21 +04:00
parent 3566fc8a58
commit e573870503
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -257,22 +257,6 @@ func (h *MindflowApiHandlers) New(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/mindflow/admin", http.StatusMovedPermanently)
}
func (h *MindflowApiHandlers) DeleteCategory(w http.ResponseWriter, r *http.Request) {
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
if err := h.db.DeleteCategory(id); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
func (h *MindflowApiHandlers) DeleteUnusedCategories(w http.ResponseWriter, r *http.Request) {
if err := h.db.DeleteUnusedCategories(); err != nil {
log.Println("Cannot delete unused categories:", err)
http.Error(w, "Cannot delete unused categories: "+err.Error(), http.StatusInternalServerError)
return
}
}
func (h *MindflowApiHandlers) Edit(w http.ResponseWriter, r *http.Request) {
var post *mindflow.Post
var err error
@ -330,3 +314,19 @@ func (h *MindflowApiHandlers) Delete(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
func (h *MindflowApiHandlers) DeleteCategory(w http.ResponseWriter, r *http.Request) {
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
if err := h.db.DeleteCategory(id); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
func (h *MindflowApiHandlers) DeleteUnusedCategories(w http.ResponseWriter, r *http.Request) {
if err := h.db.DeleteUnusedCategories(); err != nil {
log.Println("Cannot delete unused categories:", err)
http.Error(w, "Cannot delete unused categories: "+err.Error(), http.StatusInternalServerError)
return
}
}