Fixed result form stuff
This commit is contained in:
parent
0525838f4b
commit
7282d0a4b6
@ -1,9 +1,9 @@
|
||||
package forms
|
||||
|
||||
type ResultForm struct {
|
||||
Test uint `form:"result_test" validate:"required"`
|
||||
Hardware uint `form:"result_hardware" validate:"required"`
|
||||
Benchmark uint `form:"result_benchmark" validate:"required"`
|
||||
Test int `form:"result_test" validate:"required"`
|
||||
Hardware int `form:"result_hardware" validate:"required"`
|
||||
Benchmark int `form:"result_benchmark" validate:"required"`
|
||||
AverageScore float32 `form:"result_avg" validate:"required"`
|
||||
MinimumScore float32 `form:"result_min"`
|
||||
MaximumScore float32 `form:"result_max"`
|
||||
|
@ -56,6 +56,6 @@ func RegisterRoutes(f *flamego.Flame) {
|
||||
|
||||
// result routes
|
||||
f.Group("/result", func() {
|
||||
f.Post("/add", routes.ResultPostCreate)
|
||||
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ResultPostCreate)
|
||||
})
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"git.metaunix.net/bitgoblin/blt/web/forms"
|
||||
)
|
||||
|
||||
func TestPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Errors) {
|
||||
func ResultPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Errors) {
|
||||
if len(errs) > 0 {
|
||||
var err error
|
||||
switch errs[0].Category {
|
||||
@ -24,9 +24,9 @@ func TestPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Error
|
||||
}
|
||||
|
||||
result := models.Result{
|
||||
TestID: form.Test,
|
||||
HardwareID: form.Hardware,
|
||||
BenchmarkID: form.Benchmark,
|
||||
TestID: form.Test,
|
||||
HardwareID: form.Hardware,
|
||||
BenchmarkID: form.Benchmark,
|
||||
AverageScore: form.AverageScore,
|
||||
MinimumScore: form.MinimumScore,
|
||||
MaximumScore: form.MaximumScore,
|
||||
|
Loading…
Reference in New Issue
Block a user