From 466facc0097bf636b6a945a0daebb7c4c5c33c91 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 17 Mar 2015 21:51:39 -0400 Subject: #1067: Deleting users should remove them from collaborator lists - fix delete user but repository watches are not decreased --- routers/org/members.go | 4 ++-- routers/org/setting.go | 7 +++---- routers/org/teams.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'routers/org') diff --git a/routers/org/members.go b/routers/org/members.go index f571e334e1..c8c90cfe48 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -61,14 +61,14 @@ func MembersAction(ctx *middleware.Context) { return } err = org.RemoveMember(uid) - if err == models.ErrLastOrgOwner { + if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.Redirect(ctx.Org.OrgLink + "/members") return } case "leave": err = org.RemoveMember(ctx.User.Id) - if err == models.ErrLastOrgOwner { + if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.Redirect(ctx.Org.OrgLink + "/members") return diff --git a/routers/org/setting.go b/routers/org/setting.go index c638a032e7..8bc6a2a96a 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -87,13 +87,12 @@ func SettingsDelete(ctx *middleware.Context) { org := ctx.Org.Organization if ctx.Req.Method == "POST" { - // TODO: validate password. + // FIXME: validate password. if err := models.DeleteOrganization(org); err != nil { - switch err { - case models.ErrUserOwnRepos: + if models.IsErrUserOwnRepos(err) { ctx.Flash.Error(ctx.Tr("form.org_still_own_repo")) ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings/delete") - default: + } else { ctx.Handle(500, "DeleteOrganization", err) } } else { diff --git a/routers/org/teams.go b/routers/org/teams.go index 40345cf7c6..7436e30ee0 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -91,7 +91,7 @@ func TeamsAction(ctx *middleware.Context) { } if err != nil { - if err == models.ErrLastOrgOwner { + if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) } else { log.Error(3, "Action(%s): %v", ctx.Params(":action"), err) -- cgit v1.2.3