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:
parent
338bfeebe7
commit
ccfa40889a
1 changed files with 12 additions and 4 deletions
|
@ -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("")
|
||||
}
|
||||
|
|
Reference in a new issue