Started working on test edit page; removed nodemon because it wasn't working
This commit is contained in:
@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user