2015-08-18 21:24:09 -04:00
|
|
|
import Badge from "discourse/models/badge";
|
2019-10-22 09:46:10 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2015-08-18 21:24:09 -04:00
|
|
|
import UserBadge from "discourse/models/user-badge";
|
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
export default class AdminUserBadgesRoute extends DiscourseRoute {
|
2015-08-18 21:24:09 -04:00
|
|
|
model() {
|
|
|
|
const username = this.modelFor("adminUser").get("username");
|
|
|
|
return UserBadge.findByUsername(username);
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
2015-08-18 21:24:09 -04:00
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
// Find all badges.
|
|
|
|
controller.set("loading", true);
|
|
|
|
Badge.findAll().then(function (badges) {
|
|
|
|
controller.set("badges", badges);
|
|
|
|
if (badges.length > 0) {
|
2021-01-27 06:39:20 -05:00
|
|
|
let grantableBadges = controller.get("grantableBadges");
|
2015-08-18 21:24:09 -04:00
|
|
|
if (grantableBadges.length > 0) {
|
|
|
|
controller.set("selectedBadgeId", grantableBadges[0].get("id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
controller.set("loading", false);
|
|
|
|
});
|
|
|
|
// Set the model.
|
|
|
|
controller.set("model", model);
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
|
|
|
}
|