mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-05 23:34:19 -04:00
Fix broken following organization (#29005)
- following organization is broken from #28908 - add login check for the follow button in organization profile page
This commit is contained in:
parent
e936d2b338
commit
68227996a7
@ -29,6 +29,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
|
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)
|
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
|
||||||
@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.ContextUser.IsIndividual() {
|
||||||
shared_user.PrepareContextForProfileBigAvatar(ctx)
|
shared_user.PrepareContextForProfileBigAvatar(ctx)
|
||||||
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
|
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")))
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,15 @@
|
|||||||
{{svg "octicon-rss" 24}}
|
{{svg "octicon-rss" 24}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
|
{{if .IsSigned}}
|
||||||
|
<button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
|
||||||
{{if $.IsFollowing}}
|
{{if $.IsFollowing}}
|
||||||
{{ctx.Locale.Tr "user.unfollow"}}
|
{{ctx.Locale.Tr "user.unfollow"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{ctx.Locale.Tr "user.follow"}}
|
{{ctx.Locale.Tr "user.follow"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</button>
|
</button>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user