mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
32 lines
966 B
JavaScript
32 lines
966 B
JavaScript
/**
|
|
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() {
|
|
var username = this.modelFor('adminUser').get('username');
|
|
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) {
|
|
var grantableBadges = controller.get('grantableBadges');
|
|
if (grantableBadges.length > 0) {
|
|
controller.set('selectedBadgeId', grantableBadges[0].get('id'));
|
|
}
|
|
}
|
|
controller.set('loading', false);
|
|
});
|
|
// Set the model.
|
|
controller.set('model', model);
|
|
}
|
|
});
|