From fd3b4afa2b3621ece2d7d1587fd4b017142d75a0 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Sat, 17 Feb 2024 14:13:37 +0900 Subject: [PATCH] Fix broken following organization (#29005) - following organization is broken from #28908 - add login check for the follow button in organization profile page (cherry picked from commit 68227996a7a84a240b36c304d04c5c8d82948df8) --- routers/web/user/profile.go | 14 ++++++++++++-- templates/org/home.tmpl | 16 +++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 7b04948ab0..cc1953debf 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -31,6 +31,7 @@ import ( const ( tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar" + tplFollowUnfollow base.TplName = "shared/user/follow_unfollow" ) // OwnerProfile render profile page for a user or a organization (aka, repo owner) @@ -349,6 +350,15 @@ func Action(ctx *context.Context) { return } - shared_user.PrepareContextForProfileBigAvatar(ctx) - ctx.HTML(http.StatusOK, tplProfileBigAvatar) + if ctx.ContextUser.IsIndividual() { + shared_user.PrepareContextForProfileBigAvatar(ctx) + ctx.HTML(http.StatusOK, tplProfileBigAvatar) + return + } else if ctx.ContextUser.IsOrganization() { + ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) + ctx.HTML(http.StatusOK, tplFollowUnfollow) + return + } + log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type) + ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action"))) } diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index c2322b75fb..2ca60cd1be 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -30,13 +30,15 @@ {{svg "octicon-rss" 24}} {{end}} - + {{if .IsSigned}} + + {{end}}