From 9e2284048372864a7dbc5e192877ebdca04abcab Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 13 Nov 2014 05:27:01 -0500 Subject: [PATCH] fix #622 --- .bra.toml | 4 ++-- .gopmfile | 1 - cmd/serve.go | 10 +++++----- conf/locale/locale_en-US.ini | 2 ++ models/user.go | 8 ++++---- routers/admin/users.go | 3 +++ routers/user/setting.go | 3 +++ 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.bra.toml b/.bra.toml index 5fac22f584..65b3988445 100644 --- a/.bra.toml +++ b/.bra.toml @@ -14,7 +14,7 @@ watch_dirs = [ watch_exts = [".go", ".ini"] build_delay = 1500 cmds = [ - ["go", "install", "-tags", "sqlite redis cert"], - ["go", "build", "-tags", "sqlite redis cert"], + ["go", "install", "-tags", "sqlite cert"],# redis memcache + ["go", "build", "-tags", "sqlite cert"], ["./gogs", "web"] ] \ No newline at end of file diff --git a/.gopmfile b/.gopmfile index 656bc955fe..9acb0f95cb 100644 --- a/.gopmfile +++ b/.gopmfile @@ -13,7 +13,6 @@ github.com/codegangsta/cli = commit:7381bc4e62 github.com/go-sql-driver/mysql = commit:8111ee3ec3 github.com/go-xorm/core = github.com/go-xorm/xorm = -github.com/gogits/gfm = commit:40f747a9c0 github.com/gogits/oauth2 = commit:99cbec870a github.com/lib/pq = commit:b021d0ef20 github.com/macaron-contrib/binding = diff --git a/cmd/serve.go b/cmd/serve.go index c18bf3ad4b..15d48dcbfe 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -96,7 +96,7 @@ func runServ(k *cli.Context) { println("Gogs: you are not the owner of SSH key") log.GitLogger.Fatal(2, "Invalid owner of SSH key: %d", keyId) } - println("Gogs: internal error:", err) + println("Gogs: internal error:", err.Error()) log.GitLogger.Fatal(2, "Fail to get user by key ID(%d): %v", keyId, err) } @@ -125,7 +125,7 @@ func runServ(k *cli.Context) { println("Gogs: given repository owner are not registered") log.GitLogger.Fatal(2, "Unregistered owner: %s", repoUserName) } - println("Gogs: internal error:", err) + println("Gogs: internal error:", err.Error()) log.GitLogger.Fatal(2, "Fail to get repository owner(%s): %v", repoUserName, err) } @@ -134,7 +134,7 @@ func runServ(k *cli.Context) { case isWrite: has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.WRITABLE) if err != nil { - println("Gogs: internal error:", err) + println("Gogs: internal error:", err.Error()) log.GitLogger.Fatal(2, "Fail to check write access:", err) } else if !has { println("You have no right to write this repository") @@ -147,7 +147,7 @@ func runServ(k *cli.Context) { println("Gogs: given repository does not exist") log.GitLogger.Fatal(2, "Repository does not exist: %s/%s", repoUser.Name, repoName) } - println("Gogs: internal error:", err) + println("Gogs: internal error:", err.Error()) log.GitLogger.Fatal(2, "Fail to get repository: %v", err) } @@ -157,7 +157,7 @@ func runServ(k *cli.Context) { has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.READABLE) if err != nil { - println("Gogs: internal error:", err) + println("Gogs: internal error:", err.Error()) log.GitLogger.Fatal(2, "Fail to check read access:", err) } else if !has { println("You have no right to access this repository") diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 5c39340bbd..4f1442d205 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -164,6 +164,7 @@ unable_verify_ssh_key = Gogs cannot verify your SSH key, but we assume that is v auth_failed = Authentication failed: %v still_own_repo = Your account still have ownership of repository, you have to delete or transfer them first. +still_has_org = Your account still have membership of organization, you have to left or delete them first. org_still_own_repo = This organization still have ownership of repository, you have to delete or transfer them first. still_own_user = This authentication still has used by some users, you should move them and then delete again. @@ -510,6 +511,7 @@ users.is_admin = This account has administrator permissions users.update_profile = Update Account Profile users.delete_account = Delete This Account users.still_own_repo = This account still have ownership of repository, you have to delete or transfer them first. +users.still_has_org = This account still have membership of organization, you have to left or delete them first. orgs.org_manage_panel = Organization Manage Panel orgs.name = Name diff --git a/models/user.go b/models/user.go index e7e6ed409f..88fcb8388e 100644 --- a/models/user.go +++ b/models/user.go @@ -376,7 +376,7 @@ func UpdateUser(u *User) error { return err } -// TODO: need some kind of mechanism to record failure. +// FIXME: need some kind of mechanism to record failure. HINT: system notice // DeleteUser completely and permanently deletes everything of user. func DeleteUser(u *User) error { // Check ownership of repository. @@ -390,13 +390,13 @@ func DeleteUser(u *User) error { // Check membership of organization. count, err = u.GetOrganizationCount() if err != nil { - return errors.New("modesl.GetRepositories(GetOrganizationCount): " + err.Error()) + return errors.New("GetOrganizationCount: " + err.Error()) } else if count > 0 { return ErrUserHasOrgs } - // TODO: check issues, other repos' commits - // TODO: roll backable in some point. + // FIXME: check issues, other repos' commits + // FIXME: roll backable in some point. // Delete all followers. if _, err = x.Delete(&Follow{FollowId: u.Id}); err != nil { diff --git a/routers/admin/users.go b/routers/admin/users.go index 3510445329..ac33fd62b1 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -220,6 +220,9 @@ func DeleteUser(ctx *middleware.Context) { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) + case models.ErrUserHasOrgs: + ctx.Flash.Error(ctx.Tr("admin.users.still_has_org")) + ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) default: ctx.Handle(500, "DeleteUser", err) } diff --git a/routers/user/setting.go b/routers/user/setting.go index 74a3113af0..bb0fa9103e 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -311,6 +311,9 @@ func SettingsDelete(ctx *middleware.Context) { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.still_own_repo")) ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") + case models.ErrUserHasOrgs: + ctx.Flash.Error(ctx.Tr("form.still_has_org")) + ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") default: ctx.Handle(500, "DeleteUser", err) }