diff options
author | Unknwon <u@gogs.io> | 2015-12-11 18:52:28 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-11 18:52:28 -0500 |
commit | 477b4d3b50ec58998b3b078fadbef01eaf1fbeeb (patch) | |
tree | a63576c95340c4645662fffe18a76793d2435c9c | |
parent | 4d31eb2c0df89ebf029b62fec7e79dbb80773cc3 (diff) | |
download | gitea-477b4d3b50ec58998b3b078fadbef01eaf1fbeeb.tar.gz gitea-477b4d3b50ec58998b3b078fadbef01eaf1fbeeb.zip |
#2154 fix form submit error
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | cmd/web.go | 2 | ||||
-rw-r--r-- | modules/auth/user_form.go | 2 | ||||
-rwxr-xr-x | public/css/gogs.css | 2 | ||||
-rw-r--r-- | public/less/_repository.less | 2 | ||||
-rw-r--r-- | routers/user/setting.go | 39 |
6 files changed, 30 insertions, 19 deletions
@@ -1,4 +1,4 @@ -Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?branch=master)](https://travis-ci.org/gogits/gogs) [![Docker Repository on Quay](https://quay.io/repository/gogs/gogs/status "Docker Repository on Quay")](https://quay.io/repository/gogs/gogs) +Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?branch=master)](https://travis-ci.org/gogits/gogs) [![Docker Repository on Quay](https://quay.io/repository/gogs/gogs/status "Docker Repository on Quay")](https://quay.io/repository/gogs/gogs) [![Crowdin](https://d322cqt584bo4o.cloudfront.net/gogs/localized.svg)](https://crowdin.com/project/gogs) ===================== [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gogits/gogs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/cmd/web.go b/cmd/web.go index 8ff912d43b..ec8ccd5191 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -86,7 +86,7 @@ func checkVersion() { {"github.com/go-macaron/i18n", i18n.Version, "0.2.0"}, {"github.com/go-macaron/session", session.Version, "0.1.6"}, {"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"}, - {"gopkg.in/ini.v1", ini.Version, "1.8.3"}, + {"gopkg.in/ini.v1", ini.Version, "1.8.4"}, {"gopkg.in/macaron.v1", macaron.Version, "0.8.0"}, {"github.com/gogits/git-shell", git.Version, "0.1.0"}, } diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 2942940dee..d4c2dff9c0 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -87,7 +87,7 @@ func (f *SignInForm) Validate(ctx *macaron.Context, errs binding.Errors) binding // \/ \/ \/ \/ \/ type UpdateProfileForm struct { - Name string `binding:"Required;MaxSize(35)"` + Name string `binding:"OmitEmpty;MaxSize(35)"` FullName string `binding:"MaxSize(100)"` Email string `binding:"Required;Email;MaxSize(254)"` Website string `binding:"Url;MaxSize(100)"` diff --git a/public/css/gogs.css b/public/css/gogs.css index 96ee81209d..92d10ac734 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1773,9 +1773,9 @@ footer .container .links > *:first-child { } .repository .head .fork-flag { margin-left: 38px; + margin-top: 3px; display: block; font-size: 12px; - line-height: 10px; white-space: nowrap; } .repository .navbar .ui.label { diff --git a/public/less/_repository.less b/public/less/_repository.less index 06ce6414aa..e13d04195f 100644 --- a/public/less/_repository.less +++ b/public/less/_repository.less @@ -25,9 +25,9 @@ } .fork-flag { margin-left: @mega-octicon-width + 8px; + margin-top: 3px; display: block; font-size: 12px; - line-height: 10px; white-space: nowrap; } } diff --git a/routers/user/setting.go b/routers/user/setting.go index 9a9aa57e07..3cb9f0aece 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -39,41 +39,52 @@ func Settings(ctx *middleware.Context) { ctx.HTML(200, SETTINGS_PROFILE) } -func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { - ctx.Data["Title"] = ctx.Tr("settings") - ctx.Data["PageIsSettingsProfile"] = true - - if ctx.HasError() { - ctx.HTML(200, SETTINGS_PROFILE) +func handlerUsernameChange(ctx *middleware.Context, newName string) { + if len(newName) == 0 { return } // Check if user name has been changed. - if ctx.User.LowerName != strings.ToLower(form.Name) { - if err := models.ChangeUserName(ctx.User, form.Name); err != nil { + if ctx.User.LowerName != strings.ToLower(newName) { + if err := models.ChangeUserName(ctx.User, newName); err != nil { switch { case models.IsErrUserAlreadyExist(err): - ctx.Flash.Error(ctx.Tr("form.name_been_taken")) + ctx.Flash.Error(ctx.Tr("newName_been_taken")) ctx.Redirect(setting.AppSubUrl + "/user/settings") case models.IsErrEmailAlreadyUsed(err): ctx.Flash.Error(ctx.Tr("form.email_been_used")) ctx.Redirect(setting.AppSubUrl + "/user/settings") case models.IsErrNameReserved(err): - ctx.Flash.Error(ctx.Tr("user.form.name_reserved")) + ctx.Flash.Error(ctx.Tr("user.newName_reserved")) ctx.Redirect(setting.AppSubUrl + "/user/settings") case models.IsErrNamePatternNotAllowed(err): - ctx.Flash.Error(ctx.Tr("user.form.name_pattern_not_allowed")) + ctx.Flash.Error(ctx.Tr("user.newName_pattern_not_allowed")) ctx.Redirect(setting.AppSubUrl + "/user/settings") default: ctx.Handle(500, "ChangeUserName", err) } return } - log.Trace("User name changed: %s -> %s", ctx.User.Name, form.Name) + log.Trace("User name changed: %s -> %s", ctx.User.Name, newName) } // In case it's just a case change. - ctx.User.Name = form.Name - ctx.User.LowerName = strings.ToLower(form.Name) + ctx.User.Name = newName + ctx.User.LowerName = strings.ToLower(newName) +} + +func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { + ctx.Data["Title"] = ctx.Tr("settings") + ctx.Data["PageIsSettingsProfile"] = true + + if ctx.HasError() { + ctx.HTML(200, SETTINGS_PROFILE) + return + } + + handlerUsernameChange(ctx, form.Name) + if ctx.Written() { + return + } ctx.User.FullName = form.FullName ctx.User.Email = form.Email |