mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 18:01:09 +08:00
REFACTOR: support booting discourse with DISCOURSE_NO_CONSTANTS
This change is discussed here: https://meta.discourse.org/t/deprecating-es6-compatibility-layer/35821 Prior to this change we were not booting correctly with DISCOURSE_NO_CONSTANTS
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
import { propertyNotEqual } from 'discourse/lib/computed';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
import ApiKey from 'admin/models/api-key';
|
||||
import Group from 'discourse/models/group';
|
||||
import TL3Requirements from 'admin/models/tl3-requirements';
|
||||
|
||||
const AdminUser = Discourse.User.extend({
|
||||
|
||||
customGroups: Em.computed.filter("groups", (g) => !g.automatic && Discourse.Group.create(g)),
|
||||
automaticGroups: Em.computed.filter("groups", (g) => g.automatic && Discourse.Group.create(g)),
|
||||
customGroups: Em.computed.filter("groups", (g) => !g.automatic && Group.create(g)),
|
||||
automaticGroups: Em.computed.filter("groups", (g) => g.automatic && Group.create(g)),
|
||||
|
||||
generateApiKey() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/generate_api_key", {
|
||||
type: 'POST'
|
||||
}).then(function (result) {
|
||||
const apiKey = Discourse.ApiKey.create(result.api_key);
|
||||
const apiKey = ApiKey.create(result.api_key);
|
||||
self.set('api_key', apiKey);
|
||||
return apiKey;
|
||||
});
|
||||
@ -377,7 +380,7 @@ const AdminUser = Discourse.User.extend({
|
||||
}
|
||||
}
|
||||
}).catch(function() {
|
||||
Discourse.AdminUser.find( user.get('username') ).then(function(u){ user.setProperties(u); });
|
||||
AdminUser.find( user.get('username') ).then(function(u){ user.setProperties(u); });
|
||||
bootbox.alert(I18n.t("admin.user.delete_failed"));
|
||||
});
|
||||
};
|
||||
@ -450,7 +453,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
if (user.get('loadedDetails')) { return Ember.RSVP.resolve(user); }
|
||||
|
||||
return Discourse.AdminUser.find(user.get('username_lower')).then(function (result) {
|
||||
return AdminUser.find(user.get('username_lower')).then(function (result) {
|
||||
user.setProperties(result);
|
||||
user.set('loadedDetails', true);
|
||||
});
|
||||
@ -458,19 +461,19 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
tl3Requirements: function() {
|
||||
if (this.get('tl3_requirements')) {
|
||||
return Discourse.TL3Requirements.create(this.get('tl3_requirements'));
|
||||
return TL3Requirements.create(this.get('tl3_requirements'));
|
||||
}
|
||||
}.property('tl3_requirements'),
|
||||
|
||||
suspendedBy: function() {
|
||||
if (this.get('suspended_by')) {
|
||||
return Discourse.AdminUser.create(this.get('suspended_by'));
|
||||
return AdminUser.create(this.get('suspended_by'));
|
||||
}
|
||||
}.property('suspended_by'),
|
||||
|
||||
approvedBy: function() {
|
||||
if (this.get('approved_by')) {
|
||||
return Discourse.AdminUser.create(this.get('approved_by'));
|
||||
return AdminUser.create(this.get('approved_by'));
|
||||
}
|
||||
}.property('approved_by')
|
||||
|
||||
@ -511,7 +514,7 @@ AdminUser.reopenClass({
|
||||
find(username) {
|
||||
return Discourse.ajax("/admin/users/" + username + ".json").then(function (result) {
|
||||
result.loadedDetails = true;
|
||||
return Discourse.AdminUser.create(result);
|
||||
return AdminUser.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
@ -519,7 +522,7 @@ AdminUser.reopenClass({
|
||||
return Discourse.ajax("/admin/users/list/" + query + ".json", {
|
||||
data: filter
|
||||
}).then(function(users) {
|
||||
return users.map((u) => Discourse.AdminUser.create(u));
|
||||
return users.map((u) => AdminUser.create(u));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user