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>
This commit is contained in:
silverwind 2020-12-10 06:44:13 +01:00 committed by GitHub
parent 338bfeebe7
commit ccfa40889a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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("")
}