diff options
author | silverwind <me@silverwind.io> | 2020-12-10 06:44:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 00:44:13 -0500 |
commit | ccfa40889adf9f676f1c54cec5997e9356d42c70 (patch) | |
tree | a6ab0099a4d8714b7d6fda654d733bf4cff54a5e /modules | |
parent | 338bfeebe71b5ea60b6e51a064a4b7d5cd99f72f (diff) | |
download | gitea-ccfa40889adf9f676f1c54cec5997e9356d42c70.tar.gz gitea-ccfa40889adf9f676f1c54cec5997e9356d42c70.zip |
Fix avatar template error on repo collaborator page (#13924)
Fixes error `template: repo/settings/collaboration:16:16: executing
"repo/settings/collaboration" at <.>: wrong type for value; expected
*models.User; got *models.Collaborator` seen on repo collaborator page.
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/templates/helper.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index a7063d7b8d..15cbeb8151 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -550,12 +550,20 @@ func SVG(icon string, others ...interface{}) template.HTML { } // Avatar renders user avatars. args: user, size (int), class (string) -func Avatar(user *models.User, others ...interface{}) template.HTML { +func Avatar(item interface{}, others ...interface{}) template.HTML { size, class := parseOthers(models.DefaultAvatarPixelSize, "ui avatar image", others...) - src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor) - if src != "" { - return AvatarHTML(src, size, class, user.DisplayName()) + if user, ok := item.(*models.User); ok { + src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor) + if src != "" { + return AvatarHTML(src, size, class, user.DisplayName()) + } + } + if user, ok := item.(*models.Collaborator); ok { + src := user.RealSizedAvatarLink(size * models.AvatarRenderedSizeFactor) + if src != "" { + return AvatarHTML(src, size, class, user.DisplayName()) + } } return template.HTML("") } |