diff --git a/.gitignore b/.gitignore index 9c00e0a..c052e8f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,3 @@ vendor/ # Go workspace file go.work - -#IDE files -*.geany diff --git a/controllers/addOfficeHourHandler.go b/controllers/addOfficeHourHandler.go index 20c3b8d..816a874 100644 --- a/controllers/addOfficeHourHandler.go +++ b/controllers/addOfficeHourHandler.go @@ -25,17 +25,16 @@ type maskData struct { Hour int Minute int } - SelectedCourse int - SelectedRoom int - Date models.Date - Duration int - Roomname string - Name string - Email string - SubscribeToMailinglist bool - Info string - Errors []string - Config config.Config + SelectedCourse int + SelectedRoom int + Date models.Date + Duration int + Roomname string + Name string + Email string + Info string + Errors []string + Config config.Config } // Offer a form to add office hours and validate its input on receiving. @@ -130,9 +129,6 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ } else if !(b.config.Tutor.MailSuffix == "" || strings.HasSuffix(email.Address, "@"+b.config.Tutor.MailSuffix) || strings.HasSuffix(email.Address, "."+b.config.Tutor.MailSuffix)) { errors = append(errors, fmt.Sprintf("Mailaddresse muss auf „%s“ enden.", b.config.Tutor.MailSuffix)) } - - subscribeToMailinglist := req.FormValue("subscribeToMailinglist") == "subscribe" - info := req.FormValue("info") allowed, err := b.officeHourRepo.AllowedAt(date, duration, room, true) @@ -159,7 +155,6 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ roomname, name, email.Address, - subscribeToMailinglist, info, errors, b.config, @@ -169,7 +164,7 @@ func (b *BaseHandler) AddOfficeHourHandler(w http.ResponseWriter, req *http.Requ // if the data for a new office hour was sent correctly, save it. officeHour := models.OfficeHour{Id: 0, - Tutor: models.Tutor{Id: 0, Name: name, Email: email.Address, SubscribeToMailinglist: subscribeToMailinglist}, + Tutor: models.Tutor{Id: 0, Name: name, Email: email.Address}, Date: date, Room: room, RoomName: roomname, diff --git a/controllers/timetable.go b/controllers/timetable.go index 5393709..1f9b413 100644 --- a/controllers/timetable.go +++ b/controllers/timetable.go @@ -37,7 +37,7 @@ func (b *BaseHandler) GetTimetable(officeHours []models.OfficeHour) (map[models. } } slots := []int{1, 1, 1, 1, 1} - for date := range timetable { + for date, _ := range timetable { if slots[date.Day] < len(timetable[date]) { slots[date.Day] = len(timetable[date]) } diff --git a/go.mod b/go.mod index ba75534..5149708 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,6 @@ module officeHours go 1.18 -require github.com/mattn/go-sqlite3 v1.14.19 +require github.com/mattn/go-sqlite3 v1.14.18 require github.com/go-sql-driver/mysql v1.7.1 diff --git a/go.sum b/go.sum index ed38680..9b485f1 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,3 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= -github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= diff --git a/models/request.go b/models/request.go index fc71d76..49d0386 100644 --- a/models/request.go +++ b/models/request.go @@ -12,7 +12,7 @@ type Request struct { const ( RequestActivate RequestAction = iota // Fix integer to represent request for activation of an office hour. - RequestDelete // Fix integer to represent request for deletion of an office hour. + RequestDelete // Fix integer to represent request for deletion of an office hour. ) type RequestRepository interface { diff --git a/models/tutor.go b/models/tutor.go index a5a2dbc..7cf8295 100644 --- a/models/tutor.go +++ b/models/tutor.go @@ -2,10 +2,9 @@ package models type Tutor struct { - Id int - Name string - Email string - SubscribeToMailinglist bool // Wants to subscribe to the mailinglist for student assistents + Id int + Name string + Email string } type TutorRepository interface { diff --git a/officeHoursMysql.sql b/officeHoursMysql.sql index 9583ab1..fd8ef8c 100644 --- a/officeHoursMysql.sql +++ b/officeHoursMysql.sql @@ -21,8 +21,7 @@ CREATE TABLE `room` ( CREATE TABLE `tutor` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` tinytext DEFAULT NULL, - `email` tinytext DEFAULT NULL, - `subscribeToMailinglist` BOOL DEFAULT false + `email` tinytext DEFAULT NULL ); -- diff --git a/officeHoursSQLite.sql b/officeHoursSQLite.sql index 39b54e6..70f7109 100644 --- a/officeHoursSQLite.sql +++ b/officeHoursSQLite.sql @@ -53,8 +53,7 @@ DROP TABLE IF EXISTS `tutor`; CREATE TABLE `tutor` ( `id` INTEGER PRIMARY KEY, `name` tinytext DEFAULT NULL, - `email` tinytext DEFAULT NULL, - `subscribeToMailinglist` BOOL DEFAULT false + `email` tinytext DEFAULT NULL ); -- diff --git a/repositories/tutor.go b/repositories/tutor.go index 6523861..77fc32c 100644 --- a/repositories/tutor.go +++ b/repositories/tutor.go @@ -50,7 +50,7 @@ func (r *TutorRepo) Add(tutor models.Tutor) (int, error) { //Don't add identical tutors existentTutor, err := r.FindByNameAndEmail(tutor.Name, tutor.Email) if errors.Is(err, sql.ErrNoRows) { - sqlResult, err := r.db.Exec("INSERT INTO `tutor` (name, email, subscribeToMailinglist) VALUES (?,?,?)", tutor.Name, tutor.Email, tutor.SubscribeToMailinglist) + sqlResult, err := r.db.Exec("INSERT INTO `tutor` (name, email) VALUES (?,?)", tutor.Name, tutor.Email) if err != nil { err = fmt.Errorf("SQL-error inserting new tutor: %w", err) log.Println(err.Error()) @@ -67,7 +67,7 @@ func (r *TutorRepo) Add(tutor models.Tutor) (int, error) { func (r *TutorRepo) getFromRow(row *sql.Row) (models.Tutor, error) { var tutor models.Tutor - if err := row.Scan(&tutor.Id, &tutor.Name, &tutor.Email, &tutor.SubscribeToMailinglist); err != nil { + if err := row.Scan(&tutor.Id, &tutor.Name, &tutor.Email); err != nil { err = fmt.Errorf("SQL-error scanning tutor row: %w", err) log.Println(err.Error()) return models.Tutor{}, err @@ -79,7 +79,7 @@ func (r *TutorRepo) getFromRows(rows *sql.Rows) ([]models.Tutor, error) { var tutors []models.Tutor for rows.Next() { var tutor models.Tutor - if err := rows.Scan(&tutor.Id, &tutor.Name, &tutor.Email, &tutor.SubscribeToMailinglist); err != nil { + if err := rows.Scan(&tutor.Id, &tutor.Name, &tutor.Email); err != nil { err = fmt.Errorf("Error scanning tutor row: %w", err) log.Println(err.Error()) return tutors, err diff --git a/templating/templates/addMask.html b/templating/templates/addMask.html index 527d92b..e5a5e0d 100644 --- a/templating/templates/addMask.html +++ b/templating/templates/addMask.html @@ -31,13 +31,7 @@ {{end}} Die Email-Adresse dient der Vermeidung von Spam und wird nicht veröffentlicht. -
- - -
- -