mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Calls to Discourse.ajax no longer need getURL -- will be done automatically.
This commit is contained in:
@@ -8,7 +8,7 @@ Discourse.AdminApi = Discourse.Model.extend({
|
||||
|
||||
generateKey: function(){
|
||||
var adminApi = this;
|
||||
Discourse.ajax(Discourse.getURL('/admin/api/generate_key'),{type: 'POST'}).then(function (result) {
|
||||
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
|
||||
adminApi.set('key', result.key);
|
||||
});
|
||||
},
|
||||
@@ -20,6 +20,8 @@ Discourse.AdminApi = Discourse.Model.extend({
|
||||
|
||||
Discourse.AdminApi.reopenClass({
|
||||
find: function() {
|
||||
return this.getModelAjax(Discourse.getURL('/admin/api'));
|
||||
return Discourse.ajax("/admin/api").then(function(data) {
|
||||
return Discourse.AdminApi.create(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ Discourse.AdminDashboard.reopenClass({
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
find: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/dashboard")).then(function(json) {
|
||||
return Discourse.ajax("/admin/dashboard").then(function(json) {
|
||||
var model = Discourse.AdminDashboard.create(json);
|
||||
model.set('loaded', true);
|
||||
return model;
|
||||
@@ -34,7 +34,7 @@ Discourse.AdminDashboard.reopenClass({
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
fetchProblems: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/dashboard/problems"), {
|
||||
return Discourse.ajax("/admin/dashboard/problems", {
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).then(function(json) {
|
||||
|
||||
@@ -6,20 +6,12 @@
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUser = Discourse.Model.extend({
|
||||
path: (function() {
|
||||
return Discourse.getURL("/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
|
||||
adminPath: (function() {
|
||||
return Discourse.getURL("/admin/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
|
||||
Discourse.AdminUser = Discourse.User.extend({
|
||||
|
||||
deleteAllPosts: function() {
|
||||
var user = this;
|
||||
this.set('can_delete_all_posts', false);
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/delete_all_posts", {type: 'PUT'}).then(function(result){
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'}).then(function(result){
|
||||
user.set('post_count', 0);
|
||||
});
|
||||
},
|
||||
@@ -29,14 +21,14 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('admin', false);
|
||||
this.set('can_grant_admin', true);
|
||||
this.set('can_revoke_admin', false);
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||
return Discourse.ajax("/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);
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
},
|
||||
|
||||
// Revoke the user's moderation access
|
||||
@@ -44,18 +36,18 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('moderator', false);
|
||||
this.set('can_grant_moderation', true);
|
||||
this.set('can_revoke_moderation', false);
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||
return Discourse.ajax("/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);
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
},
|
||||
|
||||
refreshBrowsers: function() {
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
bootbox.alert("Message sent to all clients!");
|
||||
},
|
||||
|
||||
@@ -63,7 +55,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('can_approve', false);
|
||||
this.set('approved', true);
|
||||
this.set('approved_by', Discourse.get('currentUser'));
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
},
|
||||
|
||||
username_lower: (function() {
|
||||
@@ -91,7 +83,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
ban: function() {
|
||||
var duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10);
|
||||
if (duration > 0) {
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + this.id + "/ban", {
|
||||
Discourse.ajax("/admin/users/" + this.id + "/ban", {
|
||||
type: 'PUT',
|
||||
data: {duration: duration}
|
||||
}).then(function () {
|
||||
@@ -106,7 +98,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
},
|
||||
|
||||
unban: function() {
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + this.id + "/unban", {
|
||||
Discourse.ajax("/admin/users/" + this.id + "/unban", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
// succeeded
|
||||
@@ -119,7 +111,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
},
|
||||
|
||||
impersonate: function() {
|
||||
Discourse.ajax(Discourse.getURL("/admin/impersonate"), {
|
||||
Discourse.ajax("/admin/impersonate", {
|
||||
type: 'POST',
|
||||
data: { username_or_email: this.get('username') }
|
||||
}).then(function() {
|
||||
@@ -151,7 +143,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
var user = this;
|
||||
bootbox.confirm(Em.String.i18n("admin.user.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
|
||||
if(result) {
|
||||
Discourse.ajax(Discourse.getURL("/admin/users/") + user.get('id') + '.json', { type: 'DELETE' }).then(function(data) {
|
||||
Discourse.ajax("/admin/users/" + user.get('id') + '.json', { type: 'DELETE' }).then(function(data) {
|
||||
if (data.deleted) {
|
||||
bootbox.alert(Em.String.i18n("admin.user.deleted"), function() {
|
||||
document.location = "/admin/users/list/active";
|
||||
@@ -180,7 +172,7 @@ Discourse.AdminUser.reopenClass({
|
||||
user.set('can_approve', false);
|
||||
return user.set('selected', false);
|
||||
});
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/approve-bulk"), {
|
||||
return Discourse.ajax("/admin/users/approve-bulk", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
users: users.map(function(u) {
|
||||
@@ -191,13 +183,13 @@ Discourse.AdminUser.reopenClass({
|
||||
},
|
||||
|
||||
find: function(username) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/") + username).then(function (result) {
|
||||
return Discourse.ajax("/admin/users/" + username).then(function (result) {
|
||||
return Discourse.AdminUser.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
findAll: function(query, filter) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/users/list/") + query + ".json", {
|
||||
return Discourse.ajax("/admin/users/list/" + query + ".json", {
|
||||
data: { filter: filter }
|
||||
}).then(function(users) {
|
||||
return users.map(function(u) {
|
||||
|
||||
@@ -18,7 +18,7 @@ Discourse.EmailLog.reopenClass({
|
||||
|
||||
findAll: function(filter) {
|
||||
var result = Em.A();
|
||||
Discourse.ajax(Discourse.getURL("/admin/email_logs.json"), {
|
||||
Discourse.ajax("/admin/email_logs.json", {
|
||||
data: { filter: filter }
|
||||
}).then(function(logs) {
|
||||
logs.each(function(log) {
|
||||
|
||||
@@ -47,14 +47,14 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||
|
||||
deletePost: function() {
|
||||
if (this.get('post_number') === "1") {
|
||||
return Discourse.ajax(Discourse.getURL("/t/") + this.topic_id, { type: 'DELETE', cache: false });
|
||||
return Discourse.ajax("/t/" + this.topic_id, { type: 'DELETE', cache: false });
|
||||
} else {
|
||||
return Discourse.ajax(Discourse.getURL("/posts/") + this.id, { type: 'DELETE', cache: false });
|
||||
return Discourse.ajax("/posts/" + this.id, { type: 'DELETE', cache: false });
|
||||
}
|
||||
},
|
||||
|
||||
clearFlags: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/flags/clear/") + this.id, { type: 'POST', cache: false });
|
||||
return Discourse.ajax("/admin/flags/clear/" + this.id, { type: 'POST', cache: false });
|
||||
},
|
||||
|
||||
hiddenClass: function() {
|
||||
@@ -65,7 +65,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||
Discourse.FlaggedPost.reopenClass({
|
||||
findAll: function(filter) {
|
||||
var result = Em.A();
|
||||
Discourse.ajax(Discourse.getURL("/admin/flags/") + filter + ".json").then(function(data) {
|
||||
Discourse.ajax("/admin/flags/" + filter + ".json").then(function(data) {
|
||||
var userLookup = {};
|
||||
data.users.each(function(u) {
|
||||
userLookup[u.id] = Discourse.User.create(u);
|
||||
|
||||
@@ -138,7 +138,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
Discourse.Report.reopenClass({
|
||||
find: function(type) {
|
||||
var model = Discourse.Report.create({type: type});
|
||||
Discourse.ajax(Discourse.getURL("/admin/reports/") + type).then(function (json) {
|
||||
Discourse.ajax("/admin/reports/" + type).then(function (json) {
|
||||
// Add a percent field to each tuple
|
||||
var maxY = 0;
|
||||
json.report.data.forEach(function (row) {
|
||||
|
||||
@@ -20,7 +20,7 @@ Discourse.SiteContent = Discourse.Model.extend({
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
save: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_contents/" + this.get('content_type')), {
|
||||
return Discourse.ajax("/admin/site_contents/" + this.get('content_type'), {
|
||||
type: 'PUT',
|
||||
data: {content: this.get('content')}
|
||||
});
|
||||
@@ -31,7 +31,7 @@ Discourse.SiteContent = Discourse.Model.extend({
|
||||
Discourse.SiteContent.reopenClass({
|
||||
|
||||
find: function(type) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_contents/" + type)).then(function (data) {
|
||||
return Discourse.ajax("/admin/site_contents/" + type).then(function (data) {
|
||||
return Discourse.SiteContent.create(data.site_content);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ Discourse.SiteContentType = Discourse.Model.extend({});
|
||||
Discourse.SiteContentType.reopenClass({
|
||||
findAll: function() {
|
||||
var contentTypes = Em.A();
|
||||
Discourse.ajax(Discourse.getURL("/admin/site_content_types")).then(function(data) {
|
||||
Discourse.ajax("/admin/site_content_types").then(function(data) {
|
||||
data.forEach(function (ct) {
|
||||
contentTypes.pushObject(Discourse.SiteContentType.create(ct));
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||
};
|
||||
|
||||
var siteCustomization = this;
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_customizations") + (this.id ? '/' + this.id : ''), {
|
||||
return Discourse.ajax("/admin/site_customizations" + (this.id ? '/' + this.id : ''), {
|
||||
data: { site_customization: data },
|
||||
type: this.id ? 'PUT' : 'POST'
|
||||
}).then(function (result) {
|
||||
@@ -80,7 +80,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||
|
||||
destroy: function() {
|
||||
if(!this.id) return;
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_customizations/") + this.id, {
|
||||
return Discourse.ajax("/admin/site_customizations/" + this.id, {
|
||||
type: 'DELETE'
|
||||
});
|
||||
}
|
||||
@@ -99,7 +99,7 @@ var SiteCustomizations = Ember.ArrayProxy.extend({
|
||||
Discourse.SiteCustomization.reopenClass({
|
||||
findAll: function() {
|
||||
var customizations = SiteCustomizations.create({ content: [], loading: true });
|
||||
Discourse.ajax(Discourse.getURL("/admin/site_customizations")).then(function (data) {
|
||||
Discourse.ajax("/admin/site_customizations").then(function (data) {
|
||||
if (data) {
|
||||
data.site_customizations.each(function(c) {
|
||||
customizations.pushObject(Discourse.SiteCustomization.create(c.site_customizations));
|
||||
|
||||
@@ -72,7 +72,7 @@ Discourse.SiteSetting = Discourse.Model.extend({
|
||||
save: function() {
|
||||
// Update the setting
|
||||
var setting = this;
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_settings/") + (this.get('setting')), {
|
||||
return Discourse.ajax("/admin/site_settings/" + (this.get('setting')), {
|
||||
data: { value: this.get('value') },
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
@@ -90,7 +90,7 @@ Discourse.SiteSetting.reopenClass({
|
||||
**/
|
||||
findAll: function() {
|
||||
var result = Em.A();
|
||||
Discourse.ajax(Discourse.getURL("/admin/site_settings")).then(function (settings) {
|
||||
Discourse.ajax("/admin/site_settings").then(function (settings) {
|
||||
settings.site_settings.each(function(s) {
|
||||
s.originalValue = s.value;
|
||||
result.pushObject(Discourse.SiteSetting.create(s));
|
||||
@@ -101,7 +101,7 @@ Discourse.SiteSetting.reopenClass({
|
||||
},
|
||||
|
||||
update: function(key, value) {
|
||||
return Discourse.ajax(Discourse.getURL("/admin/site_settings/") + key, {
|
||||
return Discourse.ajax("/admin/site_settings/" + key, {
|
||||
type: 'PUT',
|
||||
data: { value: value }
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ Discourse.VersionCheck = Discourse.Model.extend({
|
||||
|
||||
Discourse.VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
return Discourse.ajax(Discourse.getURL('/admin/version_check')).then(function(json) {
|
||||
return Discourse.ajax('/admin/version_check').then(function(json) {
|
||||
return Discourse.VersionCheck.create(json);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user