diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-12-06 13:34:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-06 13:34:54 +0800 |
commit | e3081c667a44db469fac1e1de2d03b2d3106f100 (patch) | |
tree | b2d0bbefd1f1aef55adf1570c8782949a34ad819 /routers/user | |
parent | 77730db25768036a12e16cef9839b9492218303f (diff) | |
download | gitea-e3081c667a44db469fac1e1de2d03b2d3106f100.tar.gz gitea-e3081c667a44db469fac1e1de2d03b2d3106f100.zip |
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
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/home.go | 29 |
1 files changed, 26 insertions, 3 deletions
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) |