From 314193029a246c2498c6d54c085d57f7589c8dbe Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 22 Jun 2014 23:11:12 -0400 Subject: Use constants to name template file --- routers/user/setting.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'routers/user/setting.go') diff --git a/routers/user/setting.go b/routers/user/setting.go index 1fae516a..9075ee0b 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -14,12 +14,21 @@ import ( "github.com/gogits/gogs/modules/middleware" ) +const ( + SETTING base.TplName = "user/setting" + SOCIAL base.TplName = "user/social" + PASSWORD base.TplName = "user/password" + PUBLICKEY base.TplName = "user/publickey" + NOTIFICATION base.TplName = "user/notification" + SECURITY base.TplName = "user/security" +) + func Setting(ctx *middleware.Context) { ctx.Data["Title"] = "Setting" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSetting"] = true ctx.Data["Owner"] = ctx.User - ctx.HTML(200, "user/setting") + ctx.HTML(200, SETTING) } func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) { @@ -28,7 +37,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) { ctx.Data["IsUserPageSetting"] = true if ctx.HasError() { - ctx.HTML(200, "user/setting") + ctx.HTML(200, SETTING) return } @@ -90,14 +99,14 @@ func SettingSocial(ctx *middleware.Context) { ctx.Handle(500, "user.SettingSocial(GetOauthByUserId)", err) return } - ctx.HTML(200, "user/social") + ctx.HTML(200, SOCIAL) } func SettingPassword(ctx *middleware.Context) { ctx.Data["Title"] = "Password" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSettingPasswd"] = true - ctx.HTML(200, "user/password") + ctx.HTML(200, PASSWORD) } func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) { @@ -106,7 +115,7 @@ func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) { ctx.Data["IsUserPageSettingPasswd"] = true if ctx.HasError() { - ctx.HTML(200, "user/password") + ctx.HTML(200, PASSWORD) return } @@ -207,7 +216,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) { } } - ctx.HTML(200, "user/publickey") + ctx.HTML(200, PUBLICKEY) } func SettingNotification(ctx *middleware.Context) { @@ -215,7 +224,7 @@ func SettingNotification(ctx *middleware.Context) { ctx.Data["Title"] = "Notification" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSettingNotify"] = true - ctx.HTML(200, "user/notification") + ctx.HTML(200, NOTIFICATION) } func SettingSecurity(ctx *middleware.Context) { @@ -223,5 +232,5 @@ func SettingSecurity(ctx *middleware.Context) { ctx.Data["Title"] = "Security" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSettingSecurity"] = true - ctx.HTML(200, "user/security") + ctx.HTML(200, SECURITY) } -- cgit v1.2.3 From ee9b7f322ff4c4c14952c2f83fb03e90fa583cad Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 27 Jun 2014 23:14:33 -0400 Subject: Clean code --- routers/user/setting.go | 2 +- routers/user/user.go | 2 +- templates/org/settings.tmpl | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'routers/user/setting.go') diff --git a/routers/user/setting.go b/routers/user/setting.go index 9075ee0b..8e4b0840 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -68,7 +68,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) { ctx.User.Avatar = base.EncodeMd5(form.Avatar) ctx.User.AvatarEmail = form.Avatar if err := models.UpdateUser(ctx.User); err != nil { - ctx.Handle(500, "setting.Setting", err) + ctx.Handle(500, "setting.Setting(UpdateUser)", err) return } log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName) diff --git a/routers/user/user.go b/routers/user/user.go index a50f126c..a402744b 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -296,7 +296,7 @@ func DeletePost(ctx *middleware.Context) { case models.ErrUserOwnRepos: ctx.Flash.Error("Your account still have ownership of repository, you have to delete or transfer them first.") default: - ctx.Handle(500, "user.Delete", err) + ctx.Handle(500, "user.Delete(DeleteUser)", err) return } } else { diff --git a/templates/org/settings.tmpl b/templates/org/settings.tmpl index e19c027d..fd0d6a1c 100644 --- a/templates/org/settings.tmpl +++ b/templates/org/settings.tmpl @@ -98,11 +98,9 @@