From e3081c667a44db469fac1e1de2d03b2d3106f100 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 6 Dec 2019 13:34:54 +0800 Subject: Only show part of members on orgnization dashboard and add paging for orgnization members page (#9092) * Only show part of members on orgnization dashboard and add paging for orgnization members page * fix test * fix typo --- routers/user/home.go | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'routers/user') diff --git a/routers/user/home.go b/routers/user/home.go index 8465216bcf..2eff889105 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -537,14 +537,37 @@ func showOrgProfile(ctx *context.Context) { return } - if err := org.GetMembers(); err != nil { - ctx.ServerError("GetMembers", err) + var opts = models.FindOrgMembersOpts{ + OrgID: org.ID, + PublicOnly: true, + Limit: 25, + } + + if ctx.User != nil { + isMember, err := org.IsOrgMember(ctx.User.ID) + if err != nil { + ctx.Error(500, "IsOrgMember") + return + } + opts.PublicOnly = !isMember + } + + members, _, err := models.FindOrgMembers(opts) + if err != nil { + ctx.ServerError("FindOrgMembers", err) + return + } + + membersCount, err := models.CountOrgMembers(opts) + if err != nil { + ctx.ServerError("CountOrgMembers", err) return } ctx.Data["Repos"] = repos ctx.Data["Total"] = count - ctx.Data["Members"] = org.Members + ctx.Data["MembersTotal"] = membersCount + ctx.Data["Members"] = members ctx.Data["Teams"] = org.Teams pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5) -- cgit v1.2.3