FEATURE: always show highest trust level badge in card

FEATURE: fa-user icon for trust level badges
This commit is contained in:
Sam 2014-10-02 15:55:33 +10:00
parent b5c5c2fe37
commit 72a28aeb7c
3 changed files with 8 additions and 0 deletions

View File

@ -252,6 +252,10 @@ SQL
!self.multiple_grant? !self.multiple_grant?
end end
def default_icon=(val)
self.icon ||= val
end
def default_name=(val) def default_name=(val)
self.name ||= val self.name ||= val
end end

View File

@ -511,6 +511,9 @@ class User < ActiveRecord::Base
def featured_user_badges def featured_user_badges
user_badges user_badges
.joins(:badge) .joins(:badge)
.order("CASE WHEN badges.id = (SELECT MAX(ub2.badge_id) FROM user_badges ub2
WHERE ub2.badge_id IN (#{Badge.trust_level_badge_ids.join(",")}) AND
ub2.user_id = #{self.id}) THEN 1 ELSE 0 END DESC")
.order('badges.badge_type_id ASC, badges.grant_count ASC') .order('badges.badge_type_id ASC, badges.grant_count ASC')
.includes(:user, :granted_by, badge: :badge_type) .includes(:user, :granted_by, badge: :badge_type)
.where("user_badges.id in (select min(u2.id) .where("user_badges.id in (select min(u2.id)

View File

@ -56,6 +56,7 @@ trust_level_badges.each do |spec|
# allow title for tl3 and above # allow title for tl3 and above
b.default_allow_title = spec[:id] > 2 b.default_allow_title = spec[:id] > 2
b.default_icon = "fa-user"
b.system = true b.system = true
end end
end end