Mache maximale Sprechstundenlänge konfigurierbar
This commit is contained in:
parent
a631c33883
commit
5a8a248c53
5 changed files with 12 additions and 4 deletions
|
@ -16,6 +16,7 @@ type maskData struct {
|
|||
Courses []models.Course
|
||||
Rooms []models.Room
|
||||
MinuteGranularity int
|
||||
MaxDuration int
|
||||
EarliestStartTime struct {
|
||||
Hour int
|
||||
Minute int
|
||||
|
@ -109,8 +110,8 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
|||
if err != nil {
|
||||
errors = append(errors, "Die Dauer muss eine ganze Zahl sein.")
|
||||
}
|
||||
if !(duration >= b.config.Date.MinuteGranularity && duration <= 120 && duration%b.config.Date.MinuteGranularity == 0) {
|
||||
errors = append(errors, fmt.Sprintf("Sprechstunden müssen zwischen %d und 120 Minuten lang sein.", b.config.Date.MinuteGranularity))
|
||||
if !(duration >= b.config.Date.MinuteGranularity && duration <= b.config.Date.MaxDuration && duration%b.config.Date.MinuteGranularity == 0) {
|
||||
errors = append(errors, fmt.Sprintf("Sprechstunden müssen zwischen %d und %d Minuten lang sein.", b.config.Date.MinuteGranularity, b.config.Date.MaxDuration))
|
||||
}
|
||||
|
||||
roomname := req.FormValue("raumname")
|
||||
|
@ -144,6 +145,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
|||
courses,
|
||||
rooms,
|
||||
b.config.Date.MinuteGranularity,
|
||||
b.config.Date.MaxDuration,
|
||||
b.config.Date.EarliestStartTime,
|
||||
b.config.Date.LatestStartTime,
|
||||
courseid,
|
||||
|
|
|
@ -51,7 +51,7 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of
|
|||
return template.HTML("<p class=\"text-center\">Aktuell sind keine passenden Sprechstunden eingetragen.</p>")
|
||||
}
|
||||
var tableBody string
|
||||
for hour := 8; hour < 19; hour += 1 {
|
||||
for hour := b.config.Date.EarliestStartTime.Hour; hour < b.config.Date.LatestStartTime.Hour+b.config.Date.MaxDuration/60; hour += 1 {
|
||||
for minute := 0; minute < 60; minute += b.config.Date.MinuteGranularity {
|
||||
tableBody += "<tr>"
|
||||
if minute == 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue