diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/repo.go | 4 | ||||
-rw-r--r-- | routers/user/setting.go | 24 | ||||
-rw-r--r-- | routers/user/user.go | 3 |
3 files changed, 26 insertions, 5 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index a12b45d7b9..e1809b4b7e 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -46,7 +46,7 @@ func Create(form auth.CreateRepoForm, req *http.Request, r render.Render, data b if err == nil { if _, err = models.CreateRepository(user, form.RepoName, form.Description, form.Language, form.License, - form.Visibility == "private", form.InitReadme == "true"); err == nil { + form.Visibility == "private", form.InitReadme == "on"); err == nil { if err == nil { data["RepoName"] = user.Name + "/" + form.RepoName r.HTML(200, "repo/created", data) @@ -83,7 +83,7 @@ func Delete(form auth.DeleteRepoForm, req *http.Request, r render.Render, data b return } - r.Redirect("/", 200) + r.Redirect("/", 302) } func List(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { diff --git a/routers/user/setting.go b/routers/user/setting.go index 0669784be0..63e4d8cb7d 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -17,9 +17,31 @@ import ( "github.com/gogits/gogs/modules/log" ) -func Setting(r render.Render, data base.TmplData, session sessions.Session) { +func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { data["Title"] = "Setting" data["PageIsUserSetting"] = true + + user := auth.SignedInUser(session) + if req.Method == "GET" { + data["Owner"] = user + } + + if hasErr, ok := data["HasError"]; ok && hasErr.(bool) { + r.HTML(200, "user/setting", data) + return + } + + user.Email = form.Email + user.Website = form.Website + user.Location = form.Location + user.Avatar = base.EncodeMd5(form.Avatar) + if err := models.UpdateUser(user); err != nil { + data["ErrorMsg"] = err + log.Error("setting.Setting: %v", err) + r.HTML(200, "base/error", data) + return + } + r.HTML(200, "user/setting", data) } diff --git a/routers/user/user.go b/routers/user/user.go index 59177a47b9..2ce158b641 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -43,8 +43,7 @@ func Profile(params martini.Params, r render.Render, data base.TmplData, session return } - data["Avatar"] = user.Avatar - data["Username"] = user.Name + data["Owner"] = user r.HTML(200, "user/profile", data) } |