mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-17 20:12:26 +01:00
update for ical create process, new endpoints for frontend
This commit is contained in:
@@ -10,21 +10,32 @@ import (
|
||||
func GetModulesForCourseDistinct(app *pocketbase.PocketBase, c echo.Context, course string, semester string) error {
|
||||
|
||||
modules, err := db.GetAllModulesForCourse(app, course, semester)
|
||||
replaceEmptyEntry(modules, "Sonderveranstaltungen")
|
||||
replaceEmptyEntryInStringArray(modules, "Sonderveranstaltungen")
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(400, err)
|
||||
} else {
|
||||
return c.JSON(200, modules)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func replaceEmptyEntry(courses []string, replacement string) {
|
||||
func replaceEmptyEntryInStringArray(modules []string, replacement string) {
|
||||
//replace empty string with "Sonderveranstaltungen"
|
||||
for i, course := range courses {
|
||||
if checkIfOnlyWhitespace(course) {
|
||||
courses[i] = replacement
|
||||
for i, module := range modules {
|
||||
if checkIfOnlyWhitespace(module) {
|
||||
modules[i] = replacement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func replaceEmptyEntry(modules []struct {
|
||||
Name string
|
||||
Course string
|
||||
}, replacement string) {
|
||||
//replace empty string with "Sonderveranstaltungen"
|
||||
for i, module := range modules {
|
||||
if checkIfOnlyWhitespace(module.Name) {
|
||||
modules[i].Name = replacement
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,3 +49,15 @@ func checkIfOnlyWhitespace(word string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetAllModulesDistinct(app *pocketbase.PocketBase, c echo.Context) error {
|
||||
modules, err := db.GetAllModulesDistinct(app)
|
||||
|
||||
replaceEmptyEntry(modules, "Sonderveranstaltungen")
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(400, err)
|
||||
} else {
|
||||
return c.JSON(200, modules)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user