Fixed mix up between benchmark and hardware routes files
This commit is contained in:
parent
ba06a2ea4c
commit
403ab7f166
@ -14,35 +14,35 @@ import (
|
|||||||
"git.metaunix.net/bitgoblin/blt/web/forms"
|
"git.metaunix.net/bitgoblin/blt/web/forms"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HardwareGetList(t template.Template, data template.Data) {
|
func BenchmarkGetList(t template.Template, data template.Data) {
|
||||||
// add hardwares to template
|
// add benchmarks to template
|
||||||
var hardware []models.Hardware
|
var benchmarks []models.Benchmark
|
||||||
models.DB.First(&hardware)
|
models.DB.First(&benchmarks)
|
||||||
data["hardware"] = hardware
|
data["benchmarks"] = benchmarks
|
||||||
|
|
||||||
data["title"] = "List of Hardware"
|
data["title"] = "List of Benchmarks"
|
||||||
t.HTML(http.StatusOK, "hardware/list")
|
t.HTML(http.StatusOK, "benchmark/list")
|
||||||
}
|
}
|
||||||
|
|
||||||
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
|
func BenchmarkGetView(c flamego.Context, t template.Template, data template.Data) {
|
||||||
// find hardware ID from request
|
// find benchmark ID from request
|
||||||
hardwareID := c.Param("hardware_id")
|
benchmarkID := c.Param("benchmark_id")
|
||||||
|
|
||||||
// find hardware from DB
|
// find benchmark from DB
|
||||||
var hardware models.Hardware
|
var benchmark models.Benchmark
|
||||||
models.DB.Find(&hardware, hardwareID)
|
models.DB.Find(&benchmark, benchmarkID)
|
||||||
data["hardware"] = hardware
|
data["benchmark"] = benchmark
|
||||||
|
|
||||||
data["title"] = hardware.Name
|
data["title"] = benchmark.Name
|
||||||
t.HTML(http.StatusOK, "hardware/view")
|
t.HTML(http.StatusOK, "benchmark/view")
|
||||||
}
|
}
|
||||||
|
|
||||||
func HardwareGetCreate(t template.Template, data template.Data) {
|
func BenchmarkGetCreate(t template.Template, data template.Data) {
|
||||||
data["title"] = "Add New Hardware"
|
data["title"] = "Add New Benchmark"
|
||||||
t.HTML(http.StatusOK, "hardware/create")
|
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 {
|
if len(errs) > 0 {
|
||||||
var err error
|
var err error
|
||||||
switch errs[0].Category {
|
switch errs[0].Category {
|
||||||
@ -54,12 +54,12 @@ func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hardware := models.Hardware{
|
benchmark := models.Benchmark{
|
||||||
Name: form.Name,
|
Name: form.Name,
|
||||||
Type: form.Type,
|
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))
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func HardwareGetList(t template.Template, data template.Data) {
|
func HardwareGetList(t template.Template, data template.Data) {
|
||||||
// add benchmarks to template
|
// add hardwares to template
|
||||||
var benchmarks []models.Benchmark
|
var hardware []models.Hardware
|
||||||
models.DB.First(&benchmarks)
|
models.DB.First(&hardware)
|
||||||
data["benchmarks"] = benchmarks
|
data["hardware"] = hardware
|
||||||
|
|
||||||
data["title"] = "List of Benchmarks"
|
data["title"] = "List of Hardware"
|
||||||
t.HTML(http.StatusOK, "benchmark/list")
|
t.HTML(http.StatusOK, "hardware/list")
|
||||||
}
|
}
|
||||||
|
|
||||||
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
|
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user