mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:14:12 +08:00
Convert all Ajax calls to use Discourse.ajax()
This commit is contained in:
@ -18,7 +18,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
|
||||
deleteAllPosts: function() {
|
||||
this.set('can_delete_all_posts', false);
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||
},
|
||||
|
||||
// Revoke the user's admin access
|
||||
@ -26,14 +26,14 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('admin', false);
|
||||
this.set('can_grant_admin', true);
|
||||
this.set('can_revoke_admin', false);
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||
},
|
||||
|
||||
grantAdmin: function() {
|
||||
this.set('admin', true);
|
||||
this.set('can_grant_admin', false);
|
||||
this.set('can_revoke_admin', true);
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
},
|
||||
|
||||
// Revoke the user's moderation access
|
||||
@ -41,18 +41,18 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('moderator', false);
|
||||
this.set('can_grant_moderation', true);
|
||||
this.set('can_revoke_moderation', false);
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||
},
|
||||
|
||||
grantModeration: function() {
|
||||
this.set('moderator', true);
|
||||
this.set('can_grant_moderation', false);
|
||||
this.set('can_revoke_moderation', true);
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
},
|
||||
|
||||
refreshBrowsers: function() {
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
bootbox.alert("Message sent to all clients!");
|
||||
},
|
||||
|
||||
@ -60,7 +60,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('can_approve', false);
|
||||
this.set('approved', true);
|
||||
this.set('approved_by', Discourse.get('currentUser'));
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
},
|
||||
|
||||
username_lower: (function() {
|
||||
@ -90,7 +90,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
_this = this;
|
||||
if (duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10)) {
|
||||
if (duration > 0) {
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + this.id + "/ban", {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + this.id + "/ban", {
|
||||
type: 'PUT',
|
||||
data: {duration: duration},
|
||||
success: function() {
|
||||
@ -107,7 +107,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
|
||||
unban: function() {
|
||||
var _this = this;
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + this.id + "/unban", {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + this.id + "/unban", {
|
||||
type: 'PUT',
|
||||
success: function() {
|
||||
window.location.reload();
|
||||
@ -121,7 +121,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
|
||||
impersonate: function() {
|
||||
var _this = this;
|
||||
return $.ajax(Discourse.getURL("/admin/impersonate"), {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/impersonate"), {
|
||||
type: 'POST',
|
||||
data: {
|
||||
username_or_email: this.get('username')
|
||||
@ -150,7 +150,7 @@ Discourse.AdminUser.reopenClass({
|
||||
user.set('can_approve', false);
|
||||
return user.set('selected', false);
|
||||
});
|
||||
return $.ajax(Discourse.getURL("/admin/users/approve-bulk"), {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/approve-bulk"), {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
users: users.map(function(u) {
|
||||
@ -161,7 +161,7 @@ Discourse.AdminUser.reopenClass({
|
||||
},
|
||||
|
||||
find: function(username) {
|
||||
return $.ajax({url: Discourse.getURL("/admin/users/") + username}).then(function (result) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/admin/users/") + username}).then(function (result) {
|
||||
return Discourse.AdminUser.create(result);
|
||||
})
|
||||
},
|
||||
@ -169,7 +169,7 @@ Discourse.AdminUser.reopenClass({
|
||||
findAll: function(query, filter) {
|
||||
var result;
|
||||
result = Em.A();
|
||||
$.ajax({
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/admin/users/list/") + query + ".json",
|
||||
data: {
|
||||
filter: filter
|
||||
|
Reference in New Issue
Block a user