Added models; started working on project routes

This commit is contained in:
2023-11-27 23:41:48 -05:00
parent 49925c6d8f
commit 19670e9abd
8 changed files with 131 additions and 2 deletions

View File

@ -9,4 +9,15 @@ import (
func RegisterRoutes(f *flamego.Flame) {
// index routes
f.Get("/", routes.GetDashboard)
// project routes
f.Group("/project", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/project/list")
})
f.Get("/list", routes.ProjectGetList)
f.Get("/create", routes.ProjectGetCreate)
})
}

24
web/routes/project.go Normal file
View File

@ -0,0 +1,24 @@
package routes
import (
"net/http"
"github.com/flamego/template"
"git.metaunix.net/bitgoblin/blt/models"
)
func ProjectGetList(t template.Template, data template.Data) {
// add projects to template
var projects []models.Project
models.DB.Find(&projects)
data["projects"] = projects
data["title"] = "List of Projects"
t.HTML(http.StatusOK, "project/list")
}
func ProjectGetCreate(t template.Template, data template.Data) {
data["title"] = "Create a Project"
t.HTML(http.StatusOK, "project/create")
}