Aufgaben-Templates löschbar machen
This commit is contained in:
@@ -498,6 +498,27 @@ func (a *App) handleCreateTaskTemplate(w http.ResponseWriter, r *http.Request) {
|
||||
redirectWithMessage(w, r, "/planning", "info", "Template gespeichert")
|
||||
}
|
||||
|
||||
func (a *App) handleDeleteTaskTemplate(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
if err := r.ParseForm(); err != nil {
|
||||
redirectWithMessage(w, r, "/planning", "error", "Form ungültig")
|
||||
return
|
||||
}
|
||||
id := mustInt64(r.FormValue("id"), 0)
|
||||
if id <= 0 {
|
||||
redirectWithMessage(w, r, "/planning", "error", "Template-ID ungültig")
|
||||
return
|
||||
}
|
||||
if _, err := a.db.Exec(`DELETE FROM custom_task_templates WHERE id=?`, id); err != nil {
|
||||
redirectWithMessage(w, r, "/planning", "error", "Template konnte nicht gelöscht werden")
|
||||
return
|
||||
}
|
||||
redirectWithMessage(w, r, "/planning", "info", "Template gelöscht")
|
||||
}
|
||||
|
||||
func (a *App) handleCreateCustomTask(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
|
||||
@@ -69,6 +69,7 @@ func main() {
|
||||
mux.HandleFunc("/crop-steps/create", app.handleCreateCropStep)
|
||||
mux.HandleFunc("/crop-steps/delete", app.handleDeleteCropStep)
|
||||
mux.HandleFunc("/task-templates/create", app.handleCreateTaskTemplate)
|
||||
mux.HandleFunc("/task-templates/delete", app.handleDeleteTaskTemplate)
|
||||
mux.HandleFunc("/custom-tasks/create", app.handleCreateCustomTask)
|
||||
mux.HandleFunc("/custom-tasks/delete", app.handleDeleteCustomTask)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user