Erzeuge Templates zentral und nicht pro Aufruf

This commit is contained in:
Gonne 2022-09-13 07:28:13 +02:00
parent 886ccc0dcb
commit 43b3631da2
7 changed files with 32 additions and 45 deletions

View file

@ -2,7 +2,6 @@
package controllers
import (
"html/template"
"net/http"
"sprechstundentool/models"
"strconv"
@ -19,8 +18,7 @@ func (b *BaseHandler) DeleteOfficeHourHandler(w http.ResponseWriter, req *http.R
w.WriteHeader(http.StatusBadRequest)
}
_, err = b.requestRepo.Add(officeHour, models.RequestDelete)
tmpl, _ := template.New("deleteSuccess.html").ParseFiles("templates/deleteSuccess.html")
tmpl.Execute(w, struct{}{})
Templates.ExecuteTemplate(w, "deleteSuccess.html", struct{}{})
} else {
officeHours, _ := b.officeHourRepo.GetAll(true)
timetable, slots := GetTimetable(officeHours)