mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
FIX: listable badges need more logic
This commit is contained in:
parent
decff6dc85
commit
5a28609afc
@ -184,8 +184,12 @@ Discourse.Badge.reopenClass({
|
||||
@method findAll
|
||||
@returns {Promise} a promise that resolves to an array of `Discourse.Badge`
|
||||
**/
|
||||
findAll: function() {
|
||||
return Discourse.ajax('/badges.json').then(function(badgesJson) {
|
||||
findAll: function(opts) {
|
||||
var listable = "";
|
||||
if(opts && opts.onlyListable){
|
||||
listable = "?only_listable=true";
|
||||
}
|
||||
return Discourse.ajax('/badges.json' + listable).then(function(badgesJson) {
|
||||
return Discourse.Badge.createFromJson(badgesJson);
|
||||
});
|
||||
},
|
||||
|
@ -13,7 +13,7 @@ Discourse.BadgesIndexRoute = Discourse.Route.extend({
|
||||
return Discourse.Badge.createFromJson(json);
|
||||
});
|
||||
} else {
|
||||
return Discourse.Badge.findAll();
|
||||
return Discourse.Badge.findAll({onlyListable: true});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2,7 +2,9 @@ class BadgesController < ApplicationController
|
||||
skip_before_filter :check_xhr, only: [:index, :show]
|
||||
|
||||
def index
|
||||
badges = Badge.where(listable: true).all.to_a
|
||||
badges = Badge.all
|
||||
badges = badges.where(listable: true) if(params[:only_listable] == "true") || !request.xhr?
|
||||
badges = badges.to_a
|
||||
serialized = MultiJson.dump(serialize_data(badges, BadgeSerializer, root: "badges"))
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
Loading…
x
Reference in New Issue
Block a user