Commit 6822799 1 parent e936d2b commit 6822799 Copy full SHA for 6822799
File tree 2 files changed +21
-9
lines changed
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import (
29
29
30
30
const (
31
31
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32
+ tplFollowUnfollow base.TplName = "shared/user/follow_unfollow"
32
33
)
33
34
34
35
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
318
319
return
319
320
}
320
321
321
- shared_user .PrepareContextForProfileBigAvatar (ctx )
322
- ctx .HTML (http .StatusOK , tplProfileBigAvatar )
322
+ if ctx .ContextUser .IsIndividual () {
323
+ shared_user .PrepareContextForProfileBigAvatar (ctx )
324
+ ctx .HTML (http .StatusOK , tplProfileBigAvatar )
325
+ return
326
+ } else if ctx .ContextUser .IsOrganization () {
327
+ ctx .Data ["IsFollowing" ] = ctx .Doer != nil && user_model .IsFollowing (ctx , ctx .Doer .ID , ctx .ContextUser .ID )
328
+ ctx .HTML (http .StatusOK , tplFollowUnfollow )
329
+ return
330
+ }
331
+ log .Error ("Failed to apply action %q: unsupport context user type: %s" , ctx .FormString ("action" ), ctx .ContextUser .Type )
332
+ ctx .Error (http .StatusBadRequest , fmt .Sprintf ("Action %q failed" , ctx .FormString ("action" )))
323
333
}
Original file line number Diff line number Diff line change 25
25
{{svg "octicon-rss" 24}}
26
26
</a>
27
27
{{end}}
28
- <button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
29
- {{if $.IsFollowing}}
30
- {{ctx.Locale.Tr "user.unfollow"}}
31
- {{else}}
32
- {{ctx.Locale.Tr "user.follow"}}
33
- {{end}}
34
- </button>
28
+ {{if .IsSigned}}
29
+ <button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
30
+ {{if $.IsFollowing}}
31
+ {{ctx.Locale.Tr "user.unfollow"}}
32
+ {{else}}
33
+ {{ctx.Locale.Tr "user.follow"}}
34
+ {{end}}
35
+ </button>
36
+ {{end}}
35
37
</div>
36
38
</div>
37
39
You can’t perform that action at this time.
0 commit comments