Cosmetic changes.
This commit is contained in:
parent
d4cf0a58e3
commit
67a2b2598d
|
@ -8,6 +8,8 @@
|
|||
@module Discourse
|
||||
**/
|
||||
|
||||
var RESERVED_BADGE_COUNT = 100;
|
||||
|
||||
Discourse.AdminBadgeController = Discourse.ObjectController.extend({
|
||||
/**
|
||||
Whether this badge has been selected.
|
||||
|
@ -31,5 +33,5 @@ Discourse.AdminBadgeController = Discourse.ObjectController.extend({
|
|||
@property readOnly
|
||||
@type {Boolean}
|
||||
**/
|
||||
readOnly: Ember.computed.lt('model.id', 100)
|
||||
readOnly: Ember.computed.lt('model.id', RESERVED_BADGE_COUNT)
|
||||
});
|
||||
|
|
|
@ -84,8 +84,8 @@ Discourse.UserBadge.reopenClass({
|
|||
**/
|
||||
findByUsername: function(username, options) {
|
||||
var url = "/user_badges.json?username=" + username;
|
||||
if (options && options.aggregated) {
|
||||
url += "&aggregated=true";
|
||||
if (options && options.grouped) {
|
||||
url += "&grouped=true";
|
||||
}
|
||||
return Discourse.ajax(url).then(function(json) {
|
||||
return Discourse.UserBadge.createFromJson(json);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
**/
|
||||
Discourse.UserBadgesRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {aggregated: true});
|
||||
return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true});
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
|
|
|
@ -16,7 +16,7 @@ class UserBadgesController < ApplicationController
|
|||
|
||||
user_badges = user_badges.includes(:user, :granted_by, badge: :badge_type)
|
||||
|
||||
if params[:aggregated]
|
||||
if params[:grouped]
|
||||
user_badges = user_badges.group(:badge_id).select(UserBadge.attribute_names.map {|x| "MAX(#{x}) as #{x}" }, 'COUNT(*) as count')
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe UserBadgesController do
|
|||
end
|
||||
|
||||
it 'includes counts when passed the aggregate argument' do
|
||||
xhr :get, :index, username: user.username, aggregated: true
|
||||
xhr :get, :index, username: user.username, grouped: true
|
||||
|
||||
response.status.should == 200
|
||||
parsed = JSON.parse(response.body)
|
||||
|
|
Loading…
Reference in New Issue