Display badge count in the user admin page.

This commit is contained in:
Vikhyat Korrapati 2014-04-16 15:52:21 +05:30
parent e0a4959dc9
commit 4c0f85650e
4 changed files with 7 additions and 5 deletions

View File

@ -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}}

View File

@ -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

View File

@ -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

View File

@ -131,7 +131,4 @@ class UserSerializer < BasicUserSerializer
CategoryUser.lookup(object, :watching).pluck(:category_id)
end
def badge_count
object.user_badges.count
end
end