mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
Display badge count in the user admin page.
This commit is contained in:
parent
e0a4959dc9
commit
4c0f85650e
|
@ -81,7 +81,7 @@
|
|||
<div class='display-row'>
|
||||
<div class='field'>{{i18n admin.badges.title}}</div>
|
||||
<div class='value'>
|
||||
TODO featured badges
|
||||
{{i18n badges.badge_count count=badge_count}}
|
||||
</div>
|
||||
<div class='controls'>
|
||||
{{#link-to 'adminUser.badges' this class="btn"}}{{i18n admin.badges.edit_badges}}{{/link-to}}
|
||||
|
|
|
@ -492,6 +492,10 @@ class User < ActiveRecord::Base
|
|||
Summarize.new(bio_cooked).summary
|
||||
end
|
||||
|
||||
def badge_count
|
||||
user_badges.count
|
||||
end
|
||||
|
||||
def featured_user_badges
|
||||
user_badges.joins(:badge).order('badges.badge_type_id ASC, badges.grant_count ASC').includes(:granted_by, badge: :badge_type).limit(3)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
|||
:can_delete_all_posts,
|
||||
:can_be_deleted,
|
||||
:suspend_reason,
|
||||
:primary_group_id
|
||||
:primary_group_id,
|
||||
:badge_count
|
||||
|
||||
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
|
||||
has_one :api_key, serializer: ApiKeySerializer, embed: :objects
|
||||
|
|
|
@ -131,7 +131,4 @@ class UserSerializer < BasicUserSerializer
|
|||
CategoryUser.lookup(object, :watching).pluck(:category_id)
|
||||
end
|
||||
|
||||
def badge_count
|
||||
object.user_badges.count
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user