uprava i napovedy u pozice

This commit is contained in:
2025-10-23 10:27:15 +02:00
parent 335aff579c
commit dc31d4edb4
2 changed files with 14 additions and 7 deletions

View File

@@ -495,7 +495,12 @@ func AdminPositionsHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "GPS field cannot be empty", http.StatusBadRequest) http.Error(w, "GPS field cannot be empty", http.StatusBadRequest)
return return
} }
_, err := db.Exec("UPDATE positions SET gps = ? WHERE id = ?", gps, positionID) clue := r.FormValue("clue")
if clue == "" {
http.Error(w, "Clue field cannot be empty", http.StatusBadRequest)
return
}
_, err := db.Exec("UPDATE positions SET gps = ?, clue = ? WHERE id = ?", gps, clue, positionID)
if err != nil { if err != nil {
http.Error(w, "Database error", http.StatusInternalServerError) http.Error(w, "Database error", http.StatusInternalServerError)
return return

View File

@@ -19,14 +19,16 @@
{{range .}} {{range .}}
<tr> <tr>
<td>{{.ID}}</td> <td>{{.ID}}</td>
<td> <form action="/admin/positions" method="post">
<form action="/admin/positions" method="post"> <input type="hidden" name="update" value="{{.ID}}">
<td>
<input type="text" name="gps" value="{{.GPS}}"> <input type="text" name="gps" value="{{.GPS}}">
<input type="hidden" name="update" value="{{.ID}}"> </td>
<td>
<input type="text" name="clue" value="{{.Clue}}">
<input type="submit" value="Upravit"> <input type="submit" value="Upravit">
</form> </td>
</td> </form>
<td>{{.Clue}}</td>
<td><a href="{{.URL}}">{{.URL}}</a></td> <td><a href="{{.URL}}">{{.URL}}</a></td>
<td> <td>
<form action="/admin/positions" method="post"> <form action="/admin/positions" method="post">