Compare commits
No commits in common. "d91de014e90d856b3e2100b3adac8222018f8018" and "4f5dc053a08f20779a4eebc844976ce9a4cf4e66" have entirely different histories.
d91de014e9
...
4f5dc053a0
14 changed files with 56 additions and 86 deletions
|
@ -13,7 +13,6 @@ var Templates, _ = template.Must(template.ParseFiles(
|
|||
"templates/executeFailure.html",
|
||||
"templates/executeSuccess.html",
|
||||
"templates/footer.html",
|
||||
"templates/head.html",
|
||||
"templates/index.html",
|
||||
"templates/officeHourTable.html",
|
||||
"templates/requestNotFound.html")).
|
||||
|
|
2
main.go
2
main.go
|
@ -40,7 +40,7 @@ func main() {
|
|||
roomRepo := repositories.NewRoomRepo(db)
|
||||
courseRepo := repositories.NewCourseRepo(db)
|
||||
tutorRepo := repositories.NewTutorRepo(db)
|
||||
officeHourRepo := repositories.NewOfficeHourRepo(db, roomRepo, tutorRepo, courseRepo, conf)
|
||||
officeHourRepo := repositories.NewOfficeHourRepo(db, roomRepo, tutorRepo, courseRepo)
|
||||
requestRepo := repositories.NewRequestRepo(db, officeHourRepo, conf)
|
||||
h := controllers.NewBaseHandler(roomRepo, officeHourRepo, courseRepo, tutorRepo, requestRepo, conf)
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ package repositories
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"sprechstundentool/config"
|
||||
"sprechstundentool/models"
|
||||
)
|
||||
|
||||
|
@ -14,16 +12,14 @@ type OfficeHourRepo struct {
|
|||
roomRepo *RoomRepo
|
||||
tutorRepo *TutorRepo
|
||||
courseRepo *CourseRepo
|
||||
config config.Config
|
||||
}
|
||||
|
||||
func NewOfficeHourRepo(db *sql.DB, roomRepo *RoomRepo, tutorRepo *TutorRepo, courseRepo *CourseRepo, conf config.Config) *OfficeHourRepo {
|
||||
func NewOfficeHourRepo(db *sql.DB, roomRepo *RoomRepo, tutorRepo *TutorRepo, courseRepo *CourseRepo) *OfficeHourRepo {
|
||||
return &OfficeHourRepo{
|
||||
db: db,
|
||||
roomRepo: roomRepo,
|
||||
tutorRepo: tutorRepo,
|
||||
courseRepo: courseRepo,
|
||||
config: conf,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,18 +168,14 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
|
|||
return 0, err
|
||||
}
|
||||
var count int
|
||||
// iterate over all points in the new officehour to get the maximum parallel officehours
|
||||
for minute := 0; minute < duration; minute += r.config.Date.MinuteGranularity {
|
||||
var minuteCount int = 0
|
||||
for _, officeHour := range officeHours {
|
||||
// increase count if officehour starts before this point in time and ends later
|
||||
if models.DateLess(officeHour.Date, models.GetEndDate(date, minute, false)) && models.DateLess(models.GetEndDate(date, minute, false), models.GetEndDate(officeHour.Date, officeHour.Duration, false)) {
|
||||
minuteCount += 1
|
||||
}
|
||||
for _, officeHour := range officeHours {
|
||||
if models.DateLess(models.GetEndDate(officeHour.Date, officeHour.Duration, false), date) || models.GetEndDate(officeHour.Date, officeHour.Duration, false) == date {
|
||||
continue
|
||||
}
|
||||
if minuteCount > count {
|
||||
count = minuteCount
|
||||
if models.DateLess(models.GetEndDate(date, duration, false), officeHour.Date) || models.GetEndDate(date, duration, false) == officeHour.Date {
|
||||
continue
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprechstunde anlegen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
Irgendetwas ist schief gegangen. Bitte sende folgende Daten an <a href="mailto:sprechstundentool@mathebau.de">sprechstundentool@mathebau.de</a> mit einer Beschreibung, was du tun wolltest.
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprechstunde anlegen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
{{range .Errors}}{{.}}<br />{{end}}
|
||||
</p>
|
||||
<form method="POST" action="addOfficeHour">
|
||||
<label for="veranstaltung">Veranstaltung</label>:
|
||||
<select name="veranstaltung" id="veranstaltung">{{range $course := .Courses}}
|
||||
<option value="{{$course.Id}}"{{if eq $course.Id $.SelectedCourse}} selected{{end}}>{{$course.Name}}</option>{{end}}
|
||||
</select><br />
|
||||
<label for="woche">Woche</label>:
|
||||
<select name="woche" id="woche">
|
||||
<option value="0"{{if eq 0 $.Date.Week}} selected{{end}}>Jede</option>
|
||||
<option value="1"{{if eq 1 $.Date.Week}} selected{{end}}>Ungerade</option>
|
||||
<option value="2"{{if eq 2 $.Date.Week}} selected{{end}}>Gerade</option>
|
||||
</select><br />
|
||||
<label for="tag">Tag</label>: <select name="tag" id="tag">
|
||||
<option value="0"{{if eq 0 $.Date.Day}} selected{{end}}>Montag</option>
|
||||
<option value="1"{{if eq 1 $.Date.Day}} selected{{end}}>Dienstag</option>
|
||||
<option value="2"{{if eq 2 $.Date.Day}} selected{{end}}>Mittwoch</option>
|
||||
<option value="3"{{if eq 3 $.Date.Day}} selected{{end}}>Donnerstag</option>
|
||||
<option value="4"{{if eq 4 $.Date.Day}} selected{{end}}>Freitag</option>
|
||||
</select><br />
|
||||
<label for="startzeit">Startzeit</label>: <input type="time" name="startzeit" id="startzeit" min="08:00" max="17:30" {{if gt $.Date.Hour 7}}value="{{printf "%02d" $.Date.Hour}}:{{printf "%02d" $.Date.Minute}}"{{end}} required/><br />
|
||||
<label for="dauer">Dauer in Minuten</label>: <input name="dauer" id="dauer" type="number" min="{{.MinuteGranularity}}" max="120" step="{{.MinuteGranularity}}" value="{{.Duration}}" required/><br />
|
||||
<label for="raum">Raum</label>:
|
||||
<select name="raum" id="raum">{{range $room := .Rooms}}
|
||||
<option value="{{$room.Id}}"{{if eq $room.Id $.SelectedRoom}} selected{{end}}>{{$room.Name}}</option>{{end}}
|
||||
</select><br />
|
||||
<label for="raumname">Raumname (für Sonderräume)</label>: <input type="text" name="raumname" id="raumname" value="{{.Roomname}}"/><br />
|
||||
<label for="name">Name</label>: <input name="name" id="name" type="text" size="50" value="{{.Name}}" required/><br />
|
||||
<label for="email">Email-Adresse</label>:
|
||||
<input name="email" id="email" type="email" size="50" value="{{.Email}}" required/><br />
|
||||
<label for="info">Info</label>: <input name="info" id="info" type="text" size="50" value="{{.Info}}"/><br />
|
||||
<input type="submit">
|
||||
</form>
|
||||
<p>
|
||||
<form method="POST" action="addOfficeHour">
|
||||
<label for="veranstaltung">Veranstaltung</label>:
|
||||
<select name="veranstaltung">{{range $course := .Courses}}
|
||||
<option value="{{$course.Id}}"{{if eq $course.Id $.SelectedCourse}} selected{{end}}>{{$course.Name}}</option>{{end}}
|
||||
</select><br />
|
||||
<label for="woche">Woche</label>:
|
||||
<select name="woche">
|
||||
<option value="0"{{if eq 0 $.Date.Week}} selected{{end}}>Jede</option>
|
||||
<option value="1"{{if eq 1 $.Date.Week}} selected{{end}}>Gerade</option>
|
||||
<option value="2"{{if eq 2 $.Date.Week}} selected{{end}}>Ungerade</option>
|
||||
</select><br />
|
||||
<label for="tag">Tag</label>: <select name="tag">
|
||||
<option value="0"{{if eq 0 $.Date.Day}} selected{{end}}>Montag</option>
|
||||
<option value="1"{{if eq 1 $.Date.Day}} selected{{end}}>Dienstag</option>
|
||||
<option value="2"{{if eq 2 $.Date.Day}} selected{{end}}>Mittwoch</option>
|
||||
<option value="3"{{if eq 3 $.Date.Day}} selected{{end}}>Donnerstag</option>
|
||||
<option value="4"{{if eq 4 $.Date.Day}} selected{{end}}>Freitag</option>
|
||||
</select><br />
|
||||
<label for="startzeit">Startzeit</label>: <input type="time" name="startzeit" min="08:00" max="17:30" {{if gt $.Date.Hour 7}}value="{{printf "%02d" $.Date.Hour}}:{{printf "%02d" $.Date.Minute}}"{{end}} required/><br />
|
||||
<label for="dauer">Dauer in Minuten</label>: <input name="dauer" type="number" min="{{.MinuteGranularity}}" max="120" step="{{.MinuteGranularity}}" value="{{.Duration}}" required/><br />
|
||||
<label for="raum">Raum</label>:
|
||||
<select name="raum">{{range $room := .Rooms}}
|
||||
<option value="{{$room.Id}}"{{if eq $room.Id $.SelectedRoom}} selected{{end}}>{{$room.Name}}</option>{{end}}
|
||||
</select><br />
|
||||
<label for="raumname">Raumname (für Sonderräume)</label>: <input type="text" name="raumname" value="{{.Roomname}}"/><br />
|
||||
<label for="name">Name</label>: <input name="name" type="text" size="50" value="{{.Name}}" required/><br />
|
||||
<label for="email">Email-Adresse</label>:
|
||||
<input name="email" type="email" size="50" value="{{.Email}}" required/><br />
|
||||
<label for="info">Info</label>: <input name="info" type="text" size="50" value="{{.Info}}"/><br />
|
||||
<input type="submit">
|
||||
</form>
|
||||
</p>
|
||||
{{if ne .Config.Tutor.MailSuffix ""}}Du musst hier eine Email-Adresse angeben, die auf „{{.Config.Tutor.MailSuffix}}“ endet.<br />{{end}}
|
||||
Außerdem dürfen in Räumen nur begrenzt viele Sprechstunden gleichzeitig stattfinden, nämlich
|
||||
<dl>
|
||||
{{range $room := .Rooms}}
|
||||
<dt>{{$room.Name}}</dt><dd>{{$room.MaxOccupy}} Sprechstunde{{if gt $room.MaxOccupy 1}}n{{end}}</dd>{{end}}
|
||||
<dt>{{$room.Name}}</dt><dl>{{$room.MaxOccupy}} Sprechstunde{{if gt $room.MaxOccupy 1}}n{{end}}</dl><br />{{end}}
|
||||
</dl>
|
||||
{{template "footer.html" .}}
|
||||
</body>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprechstunde anlegen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
Die Sprechstunde wurde angelegt. Du solltest eine Mail mit einem Aktivierungslink erhalten haben.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprechstunde löschen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
Du solltest eine Mail mit einem Bestätigungslink erhalten haben.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Anfrage ausführen fehlgeschlagen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
Irgendetwas ist schief gegangen. Bitte sende folgende Daten an <a href="mailto:sprechstundentool@mathebau.de">sprechstundentool@mathebau.de</a> mit einer Beschreibung, was du tun wolltest.
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Anfrage ausgeführt</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
Deine Anfrage wurde ausgeführt. <br />
|
||||
Deine Anfrage wurde ausgeführt.
|
||||
{{template "footer.html" .}}
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,4 @@
|
|||
<footer>
|
||||
<a href="/">Startseite</a><br />
|
||||
<a href="/addOfficeHour">Sprechstunde anlegen</a><br />
|
||||
<a href="/deleteOfficeHour">Sprechstunde löschen</a><br />
|
||||
Technische Fragen an <a href="mailto:sprechstundentool@mathebau.de">sprechstundentool@mathebau.de</a>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="keywords" content="Mathebau, Sprechstunde, Sprechstunden, Mathe, Mathematik, technische, Universität, Darmstadt, TU, Fachschaft">
|
||||
<meta name="description" content="Eine Übersicht der Sprechstunden, die in den offenen Arbeitsräumen der Fachschaft Mathematik, TU Darmstadt, angeboten werden">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
@ -1,13 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Sprechstunden</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
<form method="GET" action="/getByCourse">
|
||||
<label for="veranstaltung">Veranstaltung: </label>
|
||||
<select name="veranstaltung" id="veranstaltung" size="1" onchange="document.forms[0].submit()">
|
||||
<select name="veranstaltung" size="1" onchange="document.forms[0].submit()">
|
||||
<option value="">Alle</option>
|
||||
{{range $course := .Courses}}
|
||||
<option value="{{$course.Id}}"{{if eq $course.Id $.SelectedCourse}} selected{{end}}>{{$course.Name}}</option>{{end}}
|
||||
|
@ -16,7 +14,7 @@
|
|||
</form>
|
||||
<form method="GET" action="/getByRoom">
|
||||
<label for="raum">Raum: </label>
|
||||
<select name="raum" id="raum" size="1" onchange="document.forms[1].submit()">
|
||||
<select name="raum" size="1" onchange="document.forms[1].submit()">
|
||||
<option value="">Alle</option>
|
||||
{{range $room := .Rooms}}
|
||||
<option value="{{$room.Id}}"{{if eq $room.Id $.SelectedRoom}} selected{{end}}>{{$room.Name}}</option>{{end}}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<html>
|
||||
<head>
|
||||
<title>Anfrage bestätigen fehlgeschlagen</title>
|
||||
{{template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
|
@ -10,7 +8,7 @@
|
|||
Bitte gib deinen Bestätigungscode hier ein.
|
||||
</p>
|
||||
<form action="/confirmRequest">
|
||||
<label for="code">Bestätigungscode</label>: <input type="text" name="code" id="code"/>
|
||||
<label for="code">Bestätigungscode</label>: <input type="text" name="code"/>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
{{template "footer.html" .}}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<td rowspan="{{divide .OfficeHour.Duration .MinuteGranularity}}" style="border: 1px solid">
|
||||
{{if .DeleteIcons}}<div style="text-align: right;"><a href="/deleteOfficeHour?id={{.OfficeHour.Id}}">❌</a></div>{{end}}
|
||||
{{printf "%02d" .OfficeHour.Date.Hour}}:{{printf "%02d" .OfficeHour.Date.Minute}} - {{printf "%02d" .OfficeHour.EndDate.Hour}}:{{printf "%02d" .OfficeHour.EndDate.Minute}}<br />
|
||||
{{if eq .OfficeHour.Date.Week 1}}in ungeraden Wochen<br />{{end}}{{if eq .OfficeHour.Date.Week 2}}in geraden Wochen<br />{{end}}
|
||||
{{.OfficeHour.Course.Name}}<br />
|
||||
{{.OfficeHour.Tutor.Name}}<br />
|
||||
{{.OfficeHour.Room.Name}}<br />
|
||||
{{if ne .OfficeHour.Info ""}}{{.OfficeHour.Info}}<br />{{end}}
|
||||
{{.OfficeHour.Room.Name}}
|
||||
</td>
|
Loading…
Reference in a new issue