From adbc22530cbc25395cb4e16ad12913ee3bacbbaa Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 29 Mar 2016 17:11:47 +1100 Subject: [PATCH] FIX: don't show badges in summary page if badges disabled --- app/assets/javascripts/discourse/models/user.js.es6 | 12 +++++++----- app/serializers/user_summary_serializer.rb | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/models/user.js.es6 b/app/assets/javascripts/discourse/models/user.js.es6 index e1199a190d9..2853625ab45 100644 --- a/app/assets/javascripts/discourse/models/user.js.es6 +++ b/app/assets/javascripts/discourse/models/user.js.es6 @@ -410,11 +410,13 @@ const User = RestModel.extend({ summary.topics = summary.topic_ids.map(id => topicMap[id]); - summary.badges = summary.badges.map(ub => { - const badge = badgeMap[ub.badge_id]; - badge.count = ub.count; - return badge; - }); + if (summary.badges) { + summary.badges = summary.badges.map(ub => { + const badge = badgeMap[ub.badge_id]; + badge.count = ub.count; + return badge; + }); + } return summary; }); } diff --git a/app/serializers/user_summary_serializer.rb b/app/serializers/user_summary_serializer.rb index 4be285f4a04..1c043d4b6ff 100644 --- a/app/serializers/user_summary_serializer.rb +++ b/app/serializers/user_summary_serializer.rb @@ -15,4 +15,8 @@ class UserSummarySerializer < ApplicationSerializer attributes :likes_given, :likes_received, :posts_read_count, :days_visited, :topic_count, :post_count + + def include_badges? + SiteSetting.enable_badges + end end