From 00f2953e7f58435944dcf7ffbac9d9839e2fc56c Mon Sep 17 00:00:00 2001 From: prokopparuzek Date: Sat, 18 Oct 2025 21:32:14 +0200 Subject: [PATCH] fix 2 --- admin.go | 5 +++-- templates.go | 1 + templates/adminRoutes.html | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/admin.go b/admin.go index e2383d7..c5cbc5d 100644 --- a/admin.go +++ b/admin.go @@ -308,7 +308,7 @@ func AdminRouteHandler(w http.ResponseWriter, r *http.Request) { var routes []AdminRouteTemplateS for _, level := range difficultyLevels { var route AdminRouteTemplateS - rows, err := db.Query("SELECT tasks.id, tasks.order_num, CIPHERS.assignment, CIPHERS.clue, tasks.end_clue, POSITIONS.gps, POSITIONS.clue, CIPHERS.solution FROM TASKS JOIN CIPHERS ON TASKS.cipher_id = ciphers.id JOIN POSITIONS on TASKS.position_id = POSITIONS.id WHERE TASKS.difficulty_level=? ORDER BY TASKS.order_num;", level.ID) + rows, err := db.Query("SELECT tasks.id, tasks.order_num, CIPHERS.assignment, CIPHERS.clue, tasks.end_clue, POSITIONS.gps, POSITIONS.clue, CIPHERS.solution, COALESCE(QR_CODES.uid, '') FROM TASKS JOIN CIPHERS ON TASKS.cipher_id = ciphers.id JOIN POSITIONS on TASKS.position_id = POSITIONS.id LEFT JOIN QR_CODES ON QR_CODES.position_id = POSITIONS.id WHERE TASKS.difficulty_level=? ORDER BY TASKS.order_num;", level.ID) if err != nil { http.Error(w, "Database error", http.StatusInternalServerError) return @@ -317,10 +317,11 @@ func AdminRouteHandler(w http.ResponseWriter, r *http.Request) { route.Name = level.LevelName for rows.Next() { var cipher CipherTemplateS - if err := rows.Scan(&cipher.ID, &cipher.Order, &cipher.Assignment, &cipher.HelpText, &cipher.FinalClue, &cipher.Coordinates, &cipher.PositionHint, &cipher.Solution); err != nil { + if err := rows.Scan(&cipher.ID, &cipher.Order, &cipher.Assignment, &cipher.HelpText, &cipher.FinalClue, &cipher.Coordinates, &cipher.PositionHint, &cipher.Solution, &cipher.URL); err != nil { http.Error(w, "Database error", http.StatusInternalServerError) return } + cipher.URL = domain + "/qr/" + cipher.URL route.Ciphers = append(route.Ciphers, cipher) } if err := rows.Err(); err != nil { diff --git a/templates.go b/templates.go index e7dc2f6..c1ce156 100644 --- a/templates.go +++ b/templates.go @@ -15,6 +15,7 @@ type CipherTemplateS struct { Solution string Help int Wrong bool + URL string } type TeamTemplateS struct { diff --git a/templates/adminRoutes.html b/templates/adminRoutes.html index dc374f4..783c4e8 100644 --- a/templates/adminRoutes.html +++ b/templates/adminRoutes.html @@ -12,6 +12,7 @@

{{.Name}}

+ @@ -19,10 +20,12 @@ + {{range .Ciphers}} + @@ -30,6 +33,7 @@ +
ID Pořadí Souřadnice Nápověda poziceNápověda Řešení Cílová indicieURL Smazat
{{.ID}} {{.Order}} {{.Coordinates}} {{.PositionHint}}{{.HelpText}} {{.Solution}} {{.FinalClue}}{{.URL}}