Added route to view test
This commit is contained in:
parent
9fd6ec6b0b
commit
a51c8aa8a4
@ -7,7 +7,7 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Latest Benchmark Results:</h3>
|
||||
<h4>Latest Benchmark Results:</h4>
|
||||
|
||||
<p>There are currently no benchmarks recorded using this hardware component.</p>
|
||||
|
||||
|
@ -7,6 +7,12 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>Latest Benchmark Results:</h4>
|
||||
|
||||
<p>There are currently no benchmarks recorded in this test.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p><a href="/test">Back</a></p>
|
||||
</div>
|
||||
|
||||
|
@ -36,5 +36,7 @@ func RegisterRoutes(f *flamego.Flame) {
|
||||
|
||||
f.Get("/create", routes.TestGetCreate)
|
||||
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
|
||||
|
||||
f.Get("{test_id}", routes.TestGetView)
|
||||
})
|
||||
}
|
||||
|
@ -24,6 +24,19 @@ func TestGetList(t template.Template, data template.Data) {
|
||||
t.HTML(http.StatusOK, "test/list")
|
||||
}
|
||||
|
||||
func TestGetView(c flamego.Context, t template.Template, data template.Data) {
|
||||
// find test ID from request
|
||||
testID := c.Param("test_id")
|
||||
|
||||
// find hardware from DB
|
||||
var test models.Test
|
||||
models.DB.Find(&test, testID)
|
||||
data["test"] = test
|
||||
|
||||
data["title"] = test.Name
|
||||
t.HTML(http.StatusOK, "test/view")
|
||||
}
|
||||
|
||||
func TestGetCreate(t template.Template, data template.Data) {
|
||||
data["title"] = "Create a Test"
|
||||
t.HTML(http.StatusOK, "test/create")
|
||||
|
Loading…
Reference in New Issue
Block a user