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='display-row'>
|
||||||
<div class='field'>{{i18n admin.badges.title}}</div>
|
<div class='field'>{{i18n admin.badges.title}}</div>
|
||||||
<div class='value'>
|
<div class='value'>
|
||||||
TODO featured badges
|
{{i18n badges.badge_count count=badge_count}}
|
||||||
</div>
|
</div>
|
||||||
<div class='controls'>
|
<div class='controls'>
|
||||||
{{#link-to 'adminUser.badges' this class="btn"}}{{i18n admin.badges.edit_badges}}{{/link-to}}
|
{{#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
|
Summarize.new(bio_cooked).summary
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def badge_count
|
||||||
|
user_badges.count
|
||||||
|
end
|
||||||
|
|
||||||
def featured_user_badges
|
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)
|
user_badges.joins(:badge).order('badges.badge_type_id ASC, badges.grant_count ASC').includes(:granted_by, badge: :badge_type).limit(3)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
||||||
:can_delete_all_posts,
|
:can_delete_all_posts,
|
||||||
:can_be_deleted,
|
:can_be_deleted,
|
||||||
:suspend_reason,
|
:suspend_reason,
|
||||||
:primary_group_id
|
:primary_group_id,
|
||||||
|
:badge_count
|
||||||
|
|
||||||
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
|
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
|
||||||
has_one :api_key, serializer: ApiKeySerializer, embed: :objects
|
has_one :api_key, serializer: ApiKeySerializer, embed: :objects
|
||||||
|
|
|
@ -131,7 +131,4 @@ class UserSerializer < BasicUserSerializer
|
||||||
CategoryUser.lookup(object, :watching).pluck(:category_id)
|
CategoryUser.lookup(object, :watching).pluck(:category_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def badge_count
|
|
||||||
object.user_badges.count
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue