Started working on test edit page; removed nodemon because it wasn't working

This commit is contained in:
2025-07-02 17:34:06 -04:00
parent 3fa86ad23d
commit 6434fd0b9c
9 changed files with 101 additions and 142 deletions

View File

@ -81,3 +81,24 @@ func TestPostCreate(c flamego.Context, form forms.TestForm, errs binding.Errors)
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
}
func TestGetEdit(c flamego.Context, t template.Template, data template.Data) {
// find test in DB
testID := c.Param("test_id")
var test models.Test
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
data["test"] = test
// add hardware components to template
var hardware []models.Hardware
models.DB.Find(&hardware)
data["hardware"] = hardware
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
t.HTML(http.StatusOK, "test/edit")
}