FEATURE: support "unlisted" badges.

This commit is contained in:
Sam 2014-07-03 17:44:16 +10:00
parent db34b534e6
commit 6bbb083d47
6 changed files with 13 additions and 3 deletions

View File

@ -70,6 +70,13 @@
</span>
</div>
<div>
<span>
{{input type="checkbox" checked=listable disabled=readOnly}}
{{i18n admin.badges.listable}}
</span>
</div>
{{#unless readOnly}}
<div class='buttons'>
<button {{action save}} {{bind-attr disabled=controller.disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>

View File

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

View File

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

View File

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

View File

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

View File

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