refactor template rendering logic to one base template
This commit is contained in:
parent
16e8cf9cd7
commit
d60b715d96
18 changed files with 199 additions and 212 deletions
|
@ -2,7 +2,6 @@ package controllers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/mail"
|
||||
"officeHours/config"
|
||||
|
@ -149,12 +148,12 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
|||
id, err := b.officeHourRepo.Add(officeHour)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
Templates.ExecuteTemplate(w, "addFailure.html", err)
|
||||
b.serveTemplate(w, "addFailure", err)
|
||||
return
|
||||
}
|
||||
officeHour, _ = b.officeHourRepo.FindById(id)
|
||||
b.requestRepo.Add(officeHour, models.RequestActivate)
|
||||
Templates.ExecuteTemplate(w, "addSuccess.html", struct{}{})
|
||||
b.serveTemplate(w, "addSuccess", nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,10 +164,5 @@ func (b *BaseHandler) writeAddOfficeHourMask(w http.ResponseWriter, req *http.Re
|
|||
if len(data.Errors) != 0 {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
err := Templates.ExecuteTemplate(w, "addMask.html", data)
|
||||
if err != nil {
|
||||
log.Printf("Template addMask.html could not be parsed: %s", err.Error())
|
||||
w.Write([]byte(fmt.Sprintf("Template konnte nicht geparst werden : %s", err.Error())))
|
||||
return
|
||||
}
|
||||
b.serveTemplate(w, "addMask", data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue