From 4529d343e31084cdf8a0e770c024e5e5da46bc7e Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 7 Aug 2023 06:41:30 +0000 Subject: [PATCH 1/5] fix --- modules/context/org.go | 15 +++++++++++++++ routers/web/org/home.go | 16 +++------------- templates/org/home.tmpl | 29 ++++++++++++++++------------- templates/org/menu.tmpl | 8 ++++---- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/modules/context/org.go b/modules/context/org.go index 835c761372fa9..2415567f0c48a 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -172,6 +172,20 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Org.OrgLink = org.AsUser().OrganisationLink() ctx.Data["OrgLink"] = ctx.Org.OrgLink + // Member + opts := &organization.FindOrgMembersOpts{ + OrgID: org.ID, + PublicOnly: true, + } + if ctx.Doer != nil { + opts.PublicOnly = !ctx.Org.IsMember && !ctx.Doer.IsAdmin + } + ctx.Data["NumMembers"], err = organization.CountOrgMembers(opts) + if err != nil { + ctx.ServerError("CountOrgMembers", err) + return + } + // Team. if ctx.Org.IsMember { shouldSeeAllTeams := false @@ -203,6 +217,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { return } } + ctx.Data["NumTeams"] = len(ctx.Org.Teams) } teamName := ctx.Params(":team") diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 7f38ec51ba6e2..ca86317c04b67 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -124,12 +124,7 @@ func Home(ctx *context.Context) { } if ctx.Doer != nil { - isMember, err := org.IsOrgMember(ctx.Doer.ID) - if err != nil { - ctx.Error(http.StatusInternalServerError, "IsOrgMember") - return - } - opts.PublicOnly = !isMember && !ctx.Doer.IsAdmin + opts.PublicOnly = !ctx.Org.IsMember && !ctx.Doer.IsAdmin } members, _, err := organization.FindOrgMembers(opts) @@ -138,12 +133,6 @@ func Home(ctx *context.Context) { return } - membersCount, err := organization.CountOrgMembers(opts) - if err != nil { - ctx.ServerError("CountOrgMembers", err) - return - } - var isFollowing bool if ctx.Doer != nil { isFollowing = user_model.IsFollowing(ctx.Doer.ID, ctx.ContextUser.ID) @@ -151,7 +140,6 @@ func Home(ctx *context.Context) { ctx.Data["Repos"] = repos ctx.Data["Total"] = count - ctx.Data["MembersTotal"] = membersCount ctx.Data["Members"] = members ctx.Data["Teams"] = ctx.Org.Teams ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull @@ -164,5 +152,7 @@ func Home(ctx *context.Context) { ctx.Data["Page"] = pager ctx.Data["ContextUser"] = ctx.ContextUser + ctx.Data["ShowMemberTeamBoard"] = ctx.Org.IsMember || len(members) > 0 + ctx.HTML(http.StatusOK, tplOrgHome) } diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 445df520a9f32..af1627b743316 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -37,12 +37,13 @@