From 0850be6750b3df69e2eb5c52e7df53705c517fbc Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Wed, 6 Sep 2023 15:38:14 +0900 Subject: [PATCH] Fix the display of org level badges (#26504) Follow #24654 #22705 #24232 In some pages we still have missing badges, for example: ![image](https://github.com/go-gitea/gitea/assets/18380374/f57fae6d-95ad-4996-8881-160c9cd27768) ![image](https://github.com/go-gitea/gitea/assets/18380374/11e86d43-b715-4d14-bdf0-51bf8b5c7b01) ![image](https://github.com/go-gitea/gitea/assets/18380374/61c514e7-d8f6-4c93-a61f-60604619e3a7) --- modules/context/org.go | 1 + modules/context/repo.go | 1 + routers/web/org/home.go | 1 - routers/web/org/members.go | 1 - routers/web/org/setting.go | 1 - routers/web/org/teams.go | 1 - routers/web/repo/packages.go | 1 - routers/web/shared/user/header.go | 1 - routers/web/user/code.go | 1 - services/context/user.go | 1 + 10 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/context/org.go b/modules/context/org.go index 2d7cf5185..7638ffdd3 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -250,6 +250,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { return } } + ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["CanReadProjects"] = ctx.Org.CanReadUnit(ctx, unit.TypeProjects) ctx.Data["CanReadPackages"] = ctx.Org.CanReadUnit(ctx, unit.TypePackages) diff --git a/modules/context/repo.go b/modules/context/repo.go index f5c56cf83..8a16d311b 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -471,6 +471,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc { } ctx.Repo.Owner = owner ctx.ContextUser = owner + ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["Username"] = ctx.Repo.Owner.Name // redirect link to wiki diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 613dff218..a69fdedba 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -152,7 +152,6 @@ func Home(ctx *context.Context) { pager.SetDefaultParams(ctx) pager.AddParam(ctx, "language", "Language") ctx.Data["Page"] = pager - ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0 diff --git a/routers/web/org/members.go b/routers/web/org/members.go index fae8b4812..3c073211a 100644 --- a/routers/web/org/members.go +++ b/routers/web/org/members.go @@ -62,7 +62,6 @@ func Members(ctx *context.Context) { } ctx.Data["Page"] = pager ctx.Data["Members"] = members - ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["MembersIsPublicMember"] = membersIsPublic ctx.Data["MembersIsUserOrgOwner"] = organization.IsUserOrgOwner(members, org.ID) ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus() diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 957daab64..51d5282fa 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -45,7 +45,6 @@ func Settings(ctx *context.Context) { ctx.Data["PageIsSettingsOptions"] = true ctx.Data["CurrentVisibility"] = ctx.Org.Organization.Visibility ctx.Data["RepoAdminChangeTeamAccess"] = ctx.Org.Organization.RepoAdminChangeTeamAccess - ctx.Data["ContextUser"] = ctx.ContextUser ctx.HTML(http.StatusOK, tplSettingsOptions) } diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 3b07bba71..fecb0cd5e 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -56,7 +56,6 @@ func Teams(ctx *context.Context) { } } ctx.Data["Teams"] = ctx.Org.Teams - ctx.Data["ContextUser"] = ctx.ContextUser ctx.HTML(http.StatusOK, tplTeams) } diff --git a/routers/web/repo/packages.go b/routers/web/repo/packages.go index 6ad2f71b5..ac9e64d77 100644 --- a/routers/web/repo/packages.go +++ b/routers/web/repo/packages.go @@ -58,7 +58,6 @@ func Packages(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("packages.title") ctx.Data["IsPackagesPage"] = true - ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["Query"] = query ctx.Data["PackageType"] = packageType ctx.Data["AvailableTypes"] = packages.TypeList diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 9b1918ed1..6273e11fc 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -22,7 +22,6 @@ import ( func prepareContextForCommonProfile(ctx *context.Context) { ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["EnableFeed"] = setting.Other.EnableFeed ctx.Data["FeedURL"] = ctx.ContextUser.HomeLink() } diff --git a/routers/web/user/code.go b/routers/web/user/code.go index 033f65c9c..29b8b91c8 100644 --- a/routers/web/user/code.go +++ b/routers/web/user/code.go @@ -30,7 +30,6 @@ func CodeSearch(ctx *context.Context) { ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled ctx.Data["Title"] = ctx.Tr("explore.code") - ctx.Data["ContextUser"] = ctx.ContextUser language := ctx.FormTrim("l") keyword := ctx.FormTrim("q") diff --git a/services/context/user.go b/services/context/user.go index 62d2dc0aa..81c274681 100644 --- a/services/context/user.go +++ b/services/context/user.go @@ -27,6 +27,7 @@ func UserAssignmentWeb() func(ctx *context.Context) { } } ctx.ContextUser = userAssignment(ctx.Base, ctx.Doer, errorFn) + ctx.Data["ContextUser"] = ctx.ContextUser } }