/** * Show edit template * Route /users/edit/profile/ */ func (u *UserController) Edit(r render.Render, di *di.DI, templateVars utils.TemplateVars) { authManager := di.AuthManager() if !authManager.IsAuthenticated() { r.HTML(403, "error/403", templateVars) return } currentUser := authManager.CurrentUser() templateVars.SetData(currentUser) r.HTML(200, "user/edit", templateVars) }
/** * Route /users/:id/view/ */ func (u *UserController) View(params martini.Params, r render.Render, di *di.DI, templateVars utils.TemplateVars) { userManager := di.UserManager() id := params["id"] user := userManager.FindById(id) if user == nil { r.HTML(404, "error/404", templateVars) } else { templateVars.SetData(user) r.HTML(200, "user/view", templateVars) } }
// Show login template func (self *UpdateLogController) List(params martini.Params, r render.Render, di *di.DI, templateVars utils.TemplateVars) { authManager := di.AuthManager() if !authManager.IsAuthenticated() { r.HTML(403, "error/403", templateVars) return } currentUser := authManager.CurrentUser() userId := currentUser.Id logs := di.UpdateLogManager().FindAll(userId) templateVars.SetData(logs) r.HTML(200, "updateLog/list", templateVars) }
/** * Routes '/', '/users/' */ func (u *UserController) List(r render.Render, di *di.DI, templateVars utils.TemplateVars) { userManager := di.UserManager() all := userManager.FindAll() templateVars.SetData(all) r.HTML(200, "user/list", templateVars) }