2014-03-19 10:27:21 -04:00
|
|
|
/**
|
|
|
|
Shows all of the badges that have been granted to a user, and allow granting and
|
|
|
|
revoking badges.
|
|
|
|
|
|
|
|
@class AdminUserBadgesRoute
|
|
|
|
@extends Discourse.Route
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.AdminUserBadgesRoute = Discourse.Route.extend({
|
|
|
|
model: function() {
|
2014-07-25 13:02:46 -04:00
|
|
|
var username = this.modelFor('adminUser').get('username');
|
2014-03-19 10:27:21 -04:00
|
|
|
return Discourse.UserBadge.findByUsername(username);
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
// Find all badges.
|
|
|
|
controller.set('loading', true);
|
|
|
|
Discourse.Badge.findAll().then(function(badges) {
|
|
|
|
controller.set('badges', badges);
|
|
|
|
if (badges.length > 0) {
|
2014-03-25 06:15:34 -04:00
|
|
|
var grantableBadges = controller.get('grantableBadges');
|
|
|
|
if (grantableBadges.length > 0) {
|
|
|
|
controller.set('selectedBadgeId', grantableBadges[0].get('id'));
|
|
|
|
}
|
2014-03-19 10:27:21 -04:00
|
|
|
}
|
|
|
|
controller.set('loading', false);
|
|
|
|
});
|
|
|
|
// Set the model.
|
|
|
|
controller.set('model', model);
|
|
|
|
}
|
|
|
|
});
|