admin team ID
This commit is contained in:
4
admin.go
4
admin.go
@@ -122,7 +122,7 @@ func adminTeamsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
// Fetch all teams with their difficulty levels
|
// Fetch all teams with their difficulty levels
|
||||||
// Teams
|
// Teams
|
||||||
rows, err := db.Query("SELECT name, difficulty_levels.level_name, last_cipher, penalty FROM teams JOIN difficulty_levels ON teams.difficulty_level = difficulty_levels.id ORDER BY teams.difficulty_level, teams.name")
|
rows, err := db.Query("SELECT teams.id, name, difficulty_levels.level_name, last_cipher, penalty FROM teams JOIN difficulty_levels ON teams.difficulty_level = difficulty_levels.id ORDER BY teams.difficulty_level, teams.name")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Database error", http.StatusInternalServerError)
|
http.Error(w, "Database error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -131,7 +131,7 @@ func adminTeamsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
var teams []TeamTemplateS
|
var teams []TeamTemplateS
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var team TeamTemplateS
|
var team TeamTemplateS
|
||||||
if err := rows.Scan(&team.TeamName, &team.Difficulty, &team.LastCipher, &team.Penalties); err != nil {
|
if err := rows.Scan(&team.ID, &team.TeamName, &team.Difficulty, &team.LastCipher, &team.Penalties); err != nil {
|
||||||
http.Error(w, "Database error", http.StatusInternalServerError)
|
http.Error(w, "Database error", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type CipherTemplateS struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TeamTemplateS struct {
|
type TeamTemplateS struct {
|
||||||
|
ID int
|
||||||
TeamName string
|
TeamName string
|
||||||
Difficulty string
|
Difficulty string
|
||||||
LastCipher int
|
LastCipher int
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<h1>Týmy</h1>
|
<h1>Týmy</h1>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
<th>Název týmu</th>
|
<th>Název týmu</th>
|
||||||
<th>Obtížnost</th>
|
<th>Obtížnost</th>
|
||||||
<th>Poslední šifra</th>
|
<th>Poslední šifra</th>
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{{range .Teams}}
|
{{range .Teams}}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{.ID}}</td>
|
||||||
<td>{{.TeamName}}</td>
|
<td>{{.TeamName}}</td>
|
||||||
<td>{{.Difficulty}}</td>
|
<td>{{.Difficulty}}</td>
|
||||||
<td>{{.LastCipher}}</td>
|
<td>{{.LastCipher}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user