mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FEATURE: include avatar flair on the avatars listed in a user summary’s “Most…” sections (#12858)
This commit is contained in:
parent
42251e2fe6
commit
d3c0b6bfe1
@ -196,9 +196,13 @@ protected
|
||||
user_ids.map do |user_id|
|
||||
lookup_hash = lookup[user_id]
|
||||
|
||||
UserWithCount.new(
|
||||
lookup_hash.attributes.merge(count: user_hash[user_id])
|
||||
) if lookup_hash.present?
|
||||
if lookup_hash.present?
|
||||
primary_group = lookup.primary_groups[user_id]
|
||||
|
||||
UserWithCount.new(
|
||||
lookup_hash.attributes.merge(count: user_hash[user_id], primary_group: primary_group)
|
||||
)
|
||||
end
|
||||
end.compact.sort_by { |u| -u[:count] }
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,18 @@ class UserSummarySerializer < ApplicationSerializer
|
||||
end
|
||||
|
||||
class UserWithCountSerializer < ApplicationSerializer
|
||||
attributes :id, :username, :name, :count, :avatar_template
|
||||
attributes :id,
|
||||
:username,
|
||||
:name,
|
||||
:count,
|
||||
:avatar_template,
|
||||
:admin,
|
||||
:moderator,
|
||||
:trust_level,
|
||||
:primary_group_flair_url,
|
||||
:primary_group_flair_bg_color,
|
||||
:primary_group_flair_color,
|
||||
:primary_group_name
|
||||
|
||||
def include_name?
|
||||
SiteSetting.enable_names?
|
||||
@ -30,6 +41,22 @@ class UserSummarySerializer < ApplicationSerializer
|
||||
def avatar_template
|
||||
User.avatar_template(object[:username], object[:uploaded_avatar_id])
|
||||
end
|
||||
|
||||
def primary_group_flair_url
|
||||
object.primary_group&.flair_icon
|
||||
end
|
||||
|
||||
def primary_group_flair_bg_color
|
||||
object.primary_group&.flair_bg_color
|
||||
end
|
||||
|
||||
def primary_group_flair_color
|
||||
object.primary_group&.flair_color
|
||||
end
|
||||
|
||||
def primary_group_name
|
||||
object.primary_group&.name
|
||||
end
|
||||
end
|
||||
|
||||
class CategoryWithCountsSerializer < ApplicationSerializer
|
||||
|
Loading…
Reference in New Issue
Block a user