diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-10-10 06:15:27 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-10-10 06:15:27 -0400 |
commit | 41dbb4c148cef33984a268e2e891b09fa10b3d94 (patch) | |
tree | 4eb5161ee98d226a1cbc66348d1c1b824630776d /routers | |
parent | 85c9f7c5f354838fc8a78977a80f9899b5158897 (diff) | |
download | gitea-41dbb4c148cef33984a268e2e891b09fa10b3d94.tar.gz gitea-41dbb4c148cef33984a268e2e891b09fa10b3d94.zip |
Hide org member in collar page
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/setting.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 0e58029ec3..971c5bef2a 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -196,9 +196,16 @@ func SettingsCollaboration(ctx *middleware.Context) { return } + // Check if user is organization member. + if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.Id) { + ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member")) + ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") + return + } + if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink, Mode: models.WRITABLE}); err != nil { - ctx.Handle(500, "AddAccess2", err) + ctx.Handle(500, "AddAccess", err) return } @@ -247,16 +254,20 @@ func SettingsCollaboration(ctx *middleware.Context) { return } - us := make([]*models.User, len(names)) - for i, name := range names { - us[i], err = models.GetUserByName(name) + collaborators := make([]*models.User, 0, len(names)) + for _, name := range names { + u, err := models.GetUserByName(name) if err != nil { ctx.Handle(500, "GetUserByName", err) return } + // Does not show organization members. + if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.Id) { + continue + } + collaborators = append(collaborators, u) } - - ctx.Data["Collaborators"] = us + ctx.Data["Collaborators"] = collaborators ctx.HTML(200, COLLABORATION) } |