diff options
Diffstat (limited to 'routers/org/members.go')
-rw-r--r-- | routers/org/members.go | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/routers/org/members.go b/routers/org/members.go index f9cb275e83..b9805c2c03 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -25,14 +25,44 @@ func Members(ctx *context.Context) { ctx.Data["Title"] = org.FullName ctx.Data["PageIsOrgMembers"] = true - if err := org.GetMembers(); err != nil { + page := ctx.QueryInt("page") + if page <= 1 { + page = 1 + } + + var opts = models.FindOrgMembersOpts{ + OrgID: org.ID, + PublicOnly: true, + } + + if ctx.User != nil { + isMember, err := ctx.Org.Organization.IsOrgMember(ctx.User.ID) + if err != nil { + ctx.Error(500, "IsOrgMember") + return + } + opts.PublicOnly = !isMember + } + + total, err := models.CountOrgMembers(opts) + if err != nil { + ctx.Error(500, "CountOrgMembers") + return + } + + pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5) + opts.Start = (page - 1) * setting.UI.MembersPagingNum + opts.Limit = setting.UI.MembersPagingNum + members, membersIsPublic, err := models.FindOrgMembers(opts) + if err != nil { ctx.ServerError("GetMembers", err) return } - ctx.Data["Members"] = org.Members - ctx.Data["MembersIsPublicMember"] = org.MembersIsPublic - ctx.Data["MembersIsUserOrgOwner"] = org.Members.IsUserOrgOwner(org.ID) - ctx.Data["MembersTwoFaStatus"] = org.Members.GetTwoFaStatus() + ctx.Data["Page"] = pager + ctx.Data["Members"] = members + ctx.Data["MembersIsPublicMember"] = membersIsPublic + ctx.Data["MembersIsUserOrgOwner"] = members.IsUserOrgOwner(org.ID) + ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus() ctx.HTML(200, tplMembers) } |