diff --git a/app/assets/javascripts/admin/templates/badges.js.handlebars b/app/assets/javascripts/admin/templates/badges.js.handlebars
index d11259b713a..e7a869f4640 100644
--- a/app/assets/javascripts/admin/templates/badges.js.handlebars
+++ b/app/assets/javascripts/admin/templates/badges.js.handlebars
@@ -70,6 +70,13 @@
+
+
+ {{input type="checkbox" checked=listable disabled=readOnly}}
+ {{i18n admin.badges.listable}}
+
+
+
{{#unless readOnly}}
diff --git a/app/assets/javascripts/discourse/models/badge.js b/app/assets/javascripts/discourse/models/badge.js
index 682534d3875..09cc799ddba 100644
--- a/app/assets/javascripts/discourse/models/badge.js
+++ b/app/assets/javascripts/discourse/models/badge.js
@@ -117,6 +117,7 @@ Discourse.Badge = Discourse.Model.extend({
badge_type_id: this.get('badge_type_id'),
allow_title: !!this.get('allow_title'),
multiple_grant: !!this.get('multiple_grant'),
+ listable: !!this.get('listable'),
icon: this.get('icon')
}
}).then(function(json) {
diff --git a/app/controllers/admin/badges_controller.rb b/app/controllers/admin/badges_controller.rb
index 33d7f7645fe..9fbf58cbf9f 100644
--- a/app/controllers/admin/badges_controller.rb
+++ b/app/controllers/admin/badges_controller.rb
@@ -30,13 +30,14 @@ class Admin::BadgesController < Admin::AdminController
end
def update_badge_from_params(badge)
- params.permit(:name, :description, :badge_type_id, :allow_title, :multiple_grant)
+ params.permit(:name, :description, :badge_type_id, :allow_title, :multiple_grant, :listable)
badge.name = params[:name]
badge.description = params[:description]
badge.badge_type = BadgeType.find(params[:badge_type_id])
badge.allow_title = params[:allow_title]
badge.multiple_grant = params[:multiple_grant]
badge.icon = params[:icon]
+ badge.listable = params[:listable]
badge
end
end
diff --git a/app/controllers/badges_controller.rb b/app/controllers/badges_controller.rb
index 06cd59080d0..d6990c1e5c7 100644
--- a/app/controllers/badges_controller.rb
+++ b/app/controllers/badges_controller.rb
@@ -2,7 +2,7 @@ class BadgesController < ApplicationController
skip_before_filter :check_xhr, only: [:index, :show]
def index
- badges = Badge.all.to_a
+ badges = Badge.where(listable: true).all.to_a
serialized = MultiJson.dump(serialize_data(badges, BadgeSerializer, root: "badges"))
respond_to do |format|
format.html do
diff --git a/app/serializers/badge_serializer.rb b/app/serializers/badge_serializer.rb
index 22111deee61..4848536ce37 100644
--- a/app/serializers/badge_serializer.rb
+++ b/app/serializers/badge_serializer.rb
@@ -1,5 +1,5 @@
class BadgeSerializer < ApplicationSerializer
- attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant, :icon
+ attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant, :icon, :listable
has_one :badge_type
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index ca64d397922..3b0a7427edb 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1873,6 +1873,7 @@ en:
no_badges: There are no badges that can be granted.
allow_title: Allow badge to be used as a title
multiple_grant: Can be granted multiple times
+ listable: Show badge on the public badges page
icon: Icon
lightbox: