uprava pozice
This commit is contained in:
16
admin.go
16
admin.go
@@ -487,6 +487,22 @@ func AdminPositionsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Redirect(w, r, "/admin/positions", http.StatusSeeOther)
|
http.Redirect(w, r, "/admin/positions", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.PostForm.Has("update") {
|
||||||
|
// Updating an existing position
|
||||||
|
positionID := r.FormValue("update")
|
||||||
|
gps := r.FormValue("gps")
|
||||||
|
if gps == "" {
|
||||||
|
http.Error(w, "GPS field cannot be empty", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err := db.Exec("UPDATE positions SET gps = ? WHERE id = ?", gps, positionID)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Database error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, "/admin/positions", http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
}
|
||||||
// Adding a new position
|
// Adding a new position
|
||||||
gps := r.FormValue("gps")
|
gps := r.FormValue("gps")
|
||||||
clue := r.FormValue("clue")
|
clue := r.FormValue("clue")
|
||||||
|
|||||||
@@ -19,7 +19,13 @@
|
|||||||
{{range .}}
|
{{range .}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{.ID}}</td>
|
<td>{{.ID}}</td>
|
||||||
<td>{{.GPS}}</td>
|
<td>
|
||||||
|
<form action="/admin/positions" method="post">
|
||||||
|
<input type="text" name="gps" value="{{.GPS}}">
|
||||||
|
<input type="hidden" name="update" value="{{.ID}}">
|
||||||
|
<input type="submit" value="Upravit">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
<td>{{.Clue}}</td>
|
<td>{{.Clue}}</td>
|
||||||
<td><a href="{{.URL}}">{{.URL}}</a></td>
|
<td><a href="{{.URL}}">{{.URL}}</a></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user