mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 00:55:32 +00:00
Started agent view
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/app"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func GetAgent(kgpz *app.KGPZ) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
return c.Render("/akteur/", nil)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,27 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/app"
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/viewmodels"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
DEFAULT_AGENT = "a"
|
||||
)
|
||||
|
||||
func GetAgents(kgpz *app.KGPZ) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
return c.Render("/akteure/", nil)
|
||||
a := c.Params("letterorid", DEFAULT_AGENT)
|
||||
a = strings.ToLower(a)
|
||||
agents := viewmodels.AgentsView(a, kgpz.Library)
|
||||
if len(agents.Agents) == 0 {
|
||||
logging.Error(nil, "No agents found for letter or id: "+a)
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
return c.Render("/akteure/", fiber.Map{"model": fiber.Map{"agents": agents, "search": a}, "title": "Akteure"})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user