Skip to content

Commit

Permalink
FEATURE: always show highest trust level badge in card
Browse files Browse the repository at this point in the history
FEATURE: fa-user icon for trust level badges
  • Loading branch information
SamSaffron committed Oct 2, 2014
1 parent b5c5c2f commit 72a28ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def single_grant?
!self.multiple_grant?
end

def default_icon=(val)
self.icon ||= val
end

def default_name=(val)
self.name ||= val
end
Expand Down
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ def badge_count
def featured_user_badges
user_badges
.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')
.includes(:user, :granted_by, badge: :badge_type)
.where("user_badges.id in (select min(u2.id)
Expand Down
1 change: 1 addition & 0 deletions db/fixtures/006_badges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

# allow title for tl3 and above
b.default_allow_title = spec[:id] > 2
b.default_icon = "fa-user"
b.system = true
end
end
Expand Down

0 comments on commit 72a28ae

Please sign in to comment.