diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-27 03:37:01 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-27 03:37:01 -0400 |
commit | 19e910428951135b9a341554dad54a6546d2ad50 (patch) | |
tree | fde86e17d1cfccd3fb42b1f57f0f1eb9f0f9b9be /routers/org/org.go | |
parent | 32b09681b2da96afe9a44790e7944c4ac51e696c (diff) | |
download | gitea-19e910428951135b9a341554dad54a6546d2ad50.tar.gz gitea-19e910428951135b9a341554dad54a6546d2ad50.zip |
Organization settings page
Diffstat (limited to 'routers/org/org.go')
-rw-r--r-- | routers/org/org.go | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/routers/org/org.go b/routers/org/org.go index 0595a81b3d..4f57b9a963 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -16,7 +16,8 @@ import ( ) const ( - NEW base.TplName = "org/new" + NEW base.TplName = "org/new" + SETTINGS base.TplName = "org/settings" ) func Organization(ctx *middleware.Context, params martini.Params) { @@ -39,7 +40,7 @@ func New(ctx *middleware.Context) { ctx.HTML(200, NEW) } -func NewPost(ctx *middleware.Context, form auth.CreateOrganizationForm) { +func NewPost(ctx *middleware.Context, form auth.CreateOrgForm) { ctx.Data["Title"] = "Create An Organization" if ctx.HasError() { @@ -114,7 +115,52 @@ func Dashboard(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, user.DASHBOARD) } -func Setting(ctx *middleware.Context, param martini.Params) { - ctx.Data["Title"] = "Setting" - ctx.HTML(200, "org/setting") +func Settings(ctx *middleware.Context, params martini.Params) { + ctx.Data["Title"] = "Settings" + + org, err := models.GetUserByName(params["org"]) + if err != nil { + if err == models.ErrUserNotExist { + ctx.Handle(404, "org.Settings(GetUserByName)", err) + } else { + ctx.Handle(500, "org.Settings(GetUserByName)", err) + } + return + } + ctx.Data["Org"] = org + + ctx.HTML(200, SETTINGS) +} + +func SettingsPost(ctx *middleware.Context, params martini.Params, form auth.OrgSettingForm) { + ctx.Data["Title"] = "Settings" + + org, err := models.GetUserByName(params["org"]) + if err != nil { + if err == models.ErrUserNotExist { + ctx.Handle(404, "org.SettingsPost(GetUserByName)", err) + } else { + ctx.Handle(500, "org.SettingsPost(GetUserByName)", err) + } + return + } + ctx.Data["Org"] = org + + if ctx.HasError() { + ctx.HTML(200, SETTINGS) + return + } + + org.FullName = form.DisplayName + org.Email = form.Email + org.Description = form.Description + org.Website = form.Website + org.Location = form.Location + if err = models.UpdateUser(org); err != nil { + ctx.Handle(500, "org.SettingsPost(UpdateUser)", err) + return + } + log.Trace("%s Organization setting updated: %s", ctx.Req.RequestURI, org.LowerName) + ctx.Flash.Success("Organization profile has been successfully updated.") + ctx.Redirect("/org/" + org.Name + "/settings") } |