Fixed mix up between benchmark and hardware routes files

This commit is contained in:
Gregory Ballantine 2024-05-29 09:12:19 -04:00
parent ba06a2ea4c
commit 403ab7f166
2 changed files with 29 additions and 29 deletions

View File

@ -14,35 +14,35 @@ import (
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func HardwareGetList(t template.Template, data template.Data) {
// add hardwares to template
var hardware []models.Hardware
models.DB.First(&hardware)
data["hardware"] = hardware
func BenchmarkGetList(t template.Template, data template.Data) {
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.First(&benchmarks)
data["benchmarks"] = benchmarks
data["title"] = "List of Hardware"
t.HTML(http.StatusOK, "hardware/list")
data["title"] = "List of Benchmarks"
t.HTML(http.StatusOK, "benchmark/list")
}
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
// find hardware ID from request
hardwareID := c.Param("hardware_id")
func BenchmarkGetView(c flamego.Context, t template.Template, data template.Data) {
// find benchmark ID from request
benchmarkID := c.Param("benchmark_id")
// find hardware from DB
var hardware models.Hardware
models.DB.Find(&hardware, hardwareID)
data["hardware"] = hardware
// find benchmark from DB
var benchmark models.Benchmark
models.DB.Find(&benchmark, benchmarkID)
data["benchmark"] = benchmark
data["title"] = hardware.Name
t.HTML(http.StatusOK, "hardware/view")
data["title"] = benchmark.Name
t.HTML(http.StatusOK, "benchmark/view")
}
func HardwareGetCreate(t template.Template, data template.Data) {
data["title"] = "Add New Hardware"
t.HTML(http.StatusOK, "hardware/create")
func BenchmarkGetCreate(t template.Template, data template.Data) {
data["title"] = "Add New Benchmark"
t.HTML(http.StatusOK, "benchmark/create")
}
func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding.Errors) {
func BenchmarkPostCreate(c flamego.Context, form forms.BenchmarkForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
@ -54,12 +54,12 @@ func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding
log.Fatal(err)
}
hardware := models.Hardware{
benchmark := models.Benchmark{
Name: form.Name,
Type: form.Type,
}
_ = models.DB.Create(&hardware)
_ = models.DB.Create(&benchmark)
c.Redirect(fmt.Sprintf("/hardware/%d", hardware.ID))
c.Redirect(fmt.Sprintf("/benchmark/%d", benchmark.ID))
}

View File

@ -15,13 +15,13 @@ import (
)
func HardwareGetList(t template.Template, data template.Data) {
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.First(&benchmarks)
data["benchmarks"] = benchmarks
// add hardwares to template
var hardware []models.Hardware
models.DB.First(&hardware)
data["hardware"] = hardware
data["title"] = "List of Benchmarks"
t.HTML(http.StatusOK, "benchmark/list")
data["title"] = "List of Hardware"
t.HTML(http.StatusOK, "hardware/list")
}
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {