go vet
This commit is contained in:
parent
d91de014e9
commit
02cac422f4
4 changed files with 17 additions and 18 deletions
|
@ -90,7 +90,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
||||||
errors = append(errors, fmt.Sprintf("Sprechstunden dürfen nur alle %d Minuten starten.", b.config.Date.MinuteGranularity))
|
errors = append(errors, fmt.Sprintf("Sprechstunden dürfen nur alle %d Minuten starten.", b.config.Date.MinuteGranularity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
date := models.Date{week, day, hour, minute}
|
date := models.Date{Week: week, Day: day, Hour: hour, Minute: minute}
|
||||||
duration, err := strconv.Atoi(req.FormValue("dauer"))
|
duration, err := strconv.Atoi(req.FormValue("dauer"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors = append(errors, "Die Dauer muss eine ganze Zahl sein.")
|
errors = append(errors, "Die Dauer muss eine ganze Zahl sein.")
|
||||||
|
@ -106,7 +106,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
||||||
}
|
}
|
||||||
email, err := mail.ParseAddress(req.FormValue("email"))
|
email, err := mail.ParseAddress(req.FormValue("email"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
email = &mail.Address{"", req.FormValue("email")}
|
email = &mail.Address{Name: "", Address: req.FormValue("email")}
|
||||||
errors = append(errors, "Mailaddresse konnte nicht geparst werden.")
|
errors = append(errors, "Mailaddresse konnte nicht geparst werden.")
|
||||||
} else if !strings.HasSuffix(email.Address, b.config.Tutor.MailSuffix) {
|
} else if !strings.HasSuffix(email.Address, b.config.Tutor.MailSuffix) {
|
||||||
errors = append(errors, fmt.Sprintf("Mailaddresse muss auf „%s“ enden.", b.config.Tutor.MailSuffix))
|
errors = append(errors, fmt.Sprintf("Mailaddresse muss auf „%s“ enden.", b.config.Tutor.MailSuffix))
|
||||||
|
@ -137,14 +137,14 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ
|
||||||
}
|
}
|
||||||
b.writeAddOfficeHourMask(w, req, data)
|
b.writeAddOfficeHourMask(w, req, data)
|
||||||
} else {
|
} else {
|
||||||
officeHour := models.OfficeHour{0,
|
officeHour := models.OfficeHour{Id: 0,
|
||||||
models.Tutor{0, name, email.Address},
|
Tutor: models.Tutor{Id: 0, Name: name, Email: email.Address},
|
||||||
date,
|
Date: date,
|
||||||
room,
|
Room: room,
|
||||||
course,
|
Course: course,
|
||||||
info,
|
Info: info,
|
||||||
false,
|
Active: false,
|
||||||
duration,
|
Duration: duration,
|
||||||
}
|
}
|
||||||
id, err := b.officeHourRepo.Add(officeHour)
|
id, err := b.officeHourRepo.Add(officeHour)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -59,16 +59,16 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of
|
||||||
}
|
}
|
||||||
for day := 0; day < 5; day += 1 {
|
for day := 0; day < 5; day += 1 {
|
||||||
for slot := 0; slot < slots[day]; slot += 1 {
|
for slot := 0; slot < slots[day]; slot += 1 {
|
||||||
current, currentExists := timetable[models.Date{0, day, hour, minute}][slot]
|
current, currentExists := timetable[models.Date{Week: 0, Day: day, Hour: hour, Minute: minute}][slot]
|
||||||
|
|
||||||
if currentExists { // This slot is taken by some office hour
|
if currentExists { // This slot is taken by some office hour
|
||||||
var continued bool = false // is this slot occupied by the same office hour the previous minute?
|
var continued bool = false // is this slot occupied by the same office hour the previous minute?
|
||||||
var predecessorExists bool
|
var predecessorExists bool
|
||||||
var predecessor models.OfficeHour
|
var predecessor models.OfficeHour
|
||||||
if hour > 0 && minute < b.config.Date.MinuteGranularity {
|
if hour > 0 && minute < b.config.Date.MinuteGranularity {
|
||||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour - 1, 60 - b.config.Date.MinuteGranularity}][slot]
|
predecessor, predecessorExists = timetable[models.Date{Week: 0, Day: day, Hour: hour - 1, Minute: 60 - b.config.Date.MinuteGranularity}][slot]
|
||||||
} else {
|
} else {
|
||||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour, minute - b.config.Date.MinuteGranularity}][slot]
|
predecessor, predecessorExists = timetable[models.Date{Week: 0, Day: day, Hour: hour, Minute: minute - b.config.Date.MinuteGranularity}][slot]
|
||||||
}
|
}
|
||||||
if predecessorExists {
|
if predecessorExists {
|
||||||
continued = (predecessor == current)
|
continued = (predecessor == current)
|
||||||
|
@ -83,7 +83,7 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of
|
||||||
OfficeHour models.OfficeHour
|
OfficeHour models.OfficeHour
|
||||||
MinuteGranularity int
|
MinuteGranularity int
|
||||||
DeleteIcons bool
|
DeleteIcons bool
|
||||||
}{current, b.config.Date.MinuteGranularity, deleteIcons}
|
}{OfficeHour: current, MinuteGranularity: b.config.Date.MinuteGranularity, DeleteIcons: deleteIcons}
|
||||||
Templates.ExecuteTemplate(&celldata, "td.html", data)
|
Templates.ExecuteTemplate(&celldata, "td.html", data)
|
||||||
tableBody += celldata.String()
|
tableBody += celldata.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ package repositories
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sprechstundentool/config"
|
"sprechstundentool/config"
|
||||||
"sprechstundentool/models"
|
"sprechstundentool/models"
|
||||||
)
|
)
|
||||||
|
@ -131,7 +130,7 @@ func (r *OfficeHourRepo) getFromRow(row *sql.Row) (models.OfficeHour, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.OfficeHour{}, fmt.Errorf("Error getting single officeHours row from database: %s", err.Error())
|
return models.OfficeHour{}, fmt.Errorf("Error getting single officeHours row from database: %s", err.Error())
|
||||||
}
|
}
|
||||||
officeHour.Date = models.Date{week, day, hour, minute}
|
officeHour.Date = models.Date{Week: week, Day: day, Hour: hour, Minute: minute}
|
||||||
officeHour.Room, _ = r.roomRepo.FindById(roomId)
|
officeHour.Room, _ = r.roomRepo.FindById(roomId)
|
||||||
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorId)
|
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorId)
|
||||||
officeHour.Course, _ = r.courseRepo.FindById(courseId)
|
officeHour.Course, _ = r.courseRepo.FindById(courseId)
|
||||||
|
@ -146,7 +145,7 @@ func (r *OfficeHourRepo) getFromRows(rows *sql.Rows) ([]models.OfficeHour, error
|
||||||
if err := rows.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration); err != nil {
|
if err := rows.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration); err != nil {
|
||||||
return officeHours, fmt.Errorf("Error getting multiple officeHour rows from database: %s", err.Error())
|
return officeHours, fmt.Errorf("Error getting multiple officeHour rows from database: %s", err.Error())
|
||||||
}
|
}
|
||||||
officeHour.Date = models.Date{week, day, hour, minute}
|
officeHour.Date = models.Date{Week: week, Day: day, Hour: hour, Minute: minute}
|
||||||
officeHour.Room, _ = r.roomRepo.FindById(roomId)
|
officeHour.Room, _ = r.roomRepo.FindById(roomId)
|
||||||
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorId)
|
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorId)
|
||||||
officeHour.Course, _ = r.courseRepo.FindById(courseId)
|
officeHour.Course, _ = r.courseRepo.FindById(courseId)
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (r *RequestRepo) Add(officeHour models.OfficeHour, action int) (int, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
request := models.Request{0, officeHour, action, secret}
|
request := models.Request{Id: 0, OfficeHour: officeHour, Action: action, Secret: secret}
|
||||||
_, err = r.db.Exec("INSERT INTO `request` (officeHour, action, secret) VALUES (?,?,?)", officeHour.Id, action, secret)
|
_, err = r.db.Exec("INSERT INTO `request` (officeHour, action, secret) VALUES (?,?,?)", officeHour.Id, action, secret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
Loading…
Reference in a new issue