diff options
Diffstat (limited to 'backend/admin')
| -rw-r--r-- | backend/admin/handler.go | 21 | ||||
| -rw-r--r-- | backend/admin/templates/game_edit.html | 2 |
2 files changed, 7 insertions, 16 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go index 7239b08..d540f57 100644 --- a/backend/admin/handler.go +++ b/backend/admin/handler.go @@ -196,16 +196,14 @@ func (h *Handler) postGameEdit(c echo.Context) error { if err != nil { return echo.NewHTTPError(http.StatusBadRequest, "Invalid duration_seconds") } - var problemID *int + var problemID int { problemIDRaw := c.FormValue("problem_id") - if problemIDRaw != "" { - problemIDInt, err := strconv.Atoi(problemIDRaw) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, "Invalid problem_id") - } - problemID = &problemIDInt + problemIDInt, err := strconv.Atoi(problemIDRaw) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, "Invalid problem_id") } + problemID = problemIDInt } var startedAt *time.Time { @@ -230,13 +228,6 @@ func (h *Handler) postGameEdit(c echo.Context) error { Valid: true, } } - var changedProblemID *int32 - if problemID == nil { - changedProblemID = nil - } else { - changedProblemID = new(int32) - *changedProblemID = int32(*problemID) - } { // TODO: @@ -255,7 +246,7 @@ func (h *Handler) postGameEdit(c echo.Context) error { DisplayName: displayName, DurationSeconds: int32(durationSeconds), StartedAt: changedStartedAt, - ProblemID: changedProblemID, + ProblemID: int32(problemID), }) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) diff --git a/backend/admin/templates/game_edit.html b/backend/admin/templates/game_edit.html index f40cc5d..c1e38a6 100644 --- a/backend/admin/templates/game_edit.html +++ b/backend/admin/templates/game_edit.html @@ -43,7 +43,7 @@ </div> <div> <label>Problem ID</label> - <input type="text" name="problem_id" value="{{ if .Game.ProblemID }}{{ .Game.ProblemID }}{{ end }}"> + <input type="text" name="problem_id" value="{{ .Game.ProblemID }}"> </div> <div> <button type="submit">Save</button> |
