mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
Calls to Discourse.ajax no longer need getURL
-- will be done automatically.
This commit is contained in:
parent
0b4fc5d81c
commit
bd99d5a40c
|
@ -26,7 +26,7 @@ Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Pres
|
|||
this.set('sentTestEmail', false);
|
||||
|
||||
var adminEmailLogsController = this;
|
||||
Discourse.ajax(Discourse.getURL("/admin/email_logs/test"), {
|
||||
Discourse.ajax("/admin/email_logs/test", {
|
||||
type: 'POST',
|
||||
data: { email_address: this.get('testEmailAddress') }
|
||||
}).then(function () {
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/**
|
||||
Return the url to a user's admin page given the username.
|
||||
For example:
|
||||
|
||||
<a href="{{unbound adminUserPath username}}">{{unbound username}}</a>
|
||||
|
||||
@method adminUserPath
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('adminUserPath', function(username) {
|
||||
return Discourse.getURL("/admin/users/") + Ember.Handlebars.get(this, username);
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
Handles routes related to users in the admin section.
|
||||
|
||||
@class AdminUserRoute
|
||||
@class AdminUserRoute
|
||||
@extends Discourse.Route
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
|
@ -11,6 +11,10 @@ Discourse.AdminUserRoute = Discourse.Route.extend({
|
|||
return Discourse.AdminUser.find(params.username);
|
||||
},
|
||||
|
||||
serialize: function(params) {
|
||||
return { username: Em.get(params, 'username').toLowerCase() };
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
this.render('admin/templates/user', {into: 'admin/templates/admin'});
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@
|
|||
{{#each top_referrers.data}}
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="title"><a href="{{unbound adminUserPath username}}">{{unbound username}}</a></td>
|
||||
<td class="title">{{#linkTo 'adminUser' this}}{{unbound username}}{{/linkTo}}</td>
|
||||
<td class="value">{{num_clicks}}</td>
|
||||
<td class="value">{{num_topics}}</td>
|
||||
</tr>
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
<td>{{date view.content.created_at}}</td>
|
||||
<td>
|
||||
{{#if view.content.user}}
|
||||
<a href="{{unbound view.content.user.adminPath}}">{{avatar view.content.user imageSize="tiny"}}</a>
|
||||
<a href="{{unbound view.content.user.adminPath}}">{{view.content.user.username}}</a>
|
||||
{{#linkTo 'adminUser' view.content.user}}{{avatar view.content.user imageSize="tiny"}}{{/linkTo}}
|
||||
{{#linkTo 'adminUser' view.content.user}}{{view.content.user.username}}{{/linkTo}}
|
||||
{{else}}
|
||||
—
|
||||
{{/if}}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<li>{{#linkTo adminFlags.active}}{{i18n admin.flags.active}}{{/linkTo}}</li>
|
||||
<li>{{#linkTo adminFlags.old}}{{i18n admin.flags.old}}{{/linkTo}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -21,12 +21,12 @@
|
|||
<tbody>
|
||||
{{#each content}}
|
||||
<tr {{bindAttr class="hiddenClass"}}>
|
||||
<td class='user'><a href="/admin{{unbound user.path}}">{{avatar user imageSize="small"}}</a></td>
|
||||
<td class='user'>{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}}</td>
|
||||
<td class='excerpt'>{{#if topicHidden}}<i title='{{i18n topic_statuses.invisible.help}}' class='icon icon-eye-close'></i> {{/if}}<h3><a href='{{unbound url}}'>{{title}}</a></h3><br>{{{excerpt}}}
|
||||
</td>
|
||||
<td class='flaggers'>{{#each flaggers}}<a href="/admin{{unbound path}}">{{avatar this imageSize="small"}}</a>{{/each}}</td>
|
||||
<td class='flaggers'>{{#each flaggers}}{{#linkTo 'adminUser' this}}{{avatar this imageSize="small"}} {{/linkTo}}{{/each}}</td>
|
||||
<td class='last-flagged'>{{date lastFlagged}}</td>
|
||||
<td class='action'>
|
||||
<td class='action'>
|
||||
{{#if controller.adminActiveFlagsView}}
|
||||
<button title='{{i18n admin.flags.clear_title}}' class='btn' {{action clearFlags this}}>{{i18n admin.flags.clear}}</button>
|
||||
<button title='{{i18n admin.flags.delete_title}}' class='btn' {{action deletePost this}}>{{i18n admin.flags.delete}}</button>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
<td class='message'>
|
||||
<div><a href="/admin{{unbound user.path}}">{{avatar user imageSize="small"}}</a> {{message}}</div>
|
||||
<div>{{#linkTo 'adminUser' user}}{{avatar user imageSize="small"}}{{/linkTo}} {{message}}</div>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<div class='field'>{{i18n user.username.title}}</div>
|
||||
<div class='value'>{{content.username}}</div>
|
||||
<div class='controls'>
|
||||
<a href="{{unbound content.path}}" class='btn'>
|
||||
{{#linkTo 'user.activity' content class="btn"}}
|
||||
<i class='icon icon-user'></i>
|
||||
{{i18n admin.user.show_public_profile}}
|
||||
</a>
|
||||
{{/linkTo}}
|
||||
{{#if content.can_impersonate}}
|
||||
<button class='btn' {{action impersonate target="content"}}>
|
||||
<i class='icon icon-screenshot'></i>
|
||||
|
@ -50,8 +50,9 @@
|
|||
<div class='value'>
|
||||
{{#if content.approved}}
|
||||
{{i18n admin.user.approved_by}}
|
||||
<a href="{{unbound content.approved_by.adminPath}}">{{avatar approved_by imageSize="small"}}</a>
|
||||
<a href="{{unbound adminPath}}">{{content.approved_by.username}}</a>
|
||||
|
||||
{{#linkTo 'adminUser' content.approved_by}}{{avatar approved_by imageSize="small"}}{{/linkTo}}
|
||||
{{#linkTo 'adminUser' content.approved_by}}{{content.approved_by.username}}{{/linkTo}}
|
||||
{{else}}
|
||||
{{i18n no_value}}
|
||||
{{/if}}
|
||||
|
|
|
@ -56,10 +56,8 @@
|
|||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
<a href="{{unbound adminPath}}">{{avatar this imageSize="small"}}</a>
|
||||
</td>
|
||||
<td><a href="{{unbound adminPath}}">{{unbound username}}</a></td>
|
||||
<td>{{#linkTo 'adminUser' this}}{{avatar this imageSize="small"}}{{/linkTo}}</td>
|
||||
<td>{{#linkTo 'adminUser' this}}{{unbound username}}{{/linkTo}}</td>
|
||||
<td>{{shorten email}}</td>
|
||||
<td>{{{unbound last_emailed_age}}}</td>
|
||||
<td>{{{unbound last_seen_age}}}</td>
|
||||
|
|
|
@ -23,6 +23,10 @@ Discourse = Ember.Application.createWithMixins({
|
|||
highestSeenByTopic: {},
|
||||
|
||||
getURL: function(url) {
|
||||
|
||||
// If it's a non relative URL, return it.
|
||||
if (url.indexOf('http') === 0) return url;
|
||||
|
||||
var u = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri);
|
||||
if (u[u.length-1] === '/') {
|
||||
u = u.substring(0, u.length-1);
|
||||
|
@ -173,7 +177,7 @@ Discourse = Ember.Application.createWithMixins({
|
|||
**/
|
||||
logout: function() {
|
||||
Discourse.KeyValueStore.abandonLocal();
|
||||
Discourse.ajax(Discourse.getURL("/session/") + this.get('currentUser.username'), {
|
||||
Discourse.ajax("/session/" + this.get('currentUser.username'), {
|
||||
type: 'DELETE'
|
||||
}).then(function() {
|
||||
// Reloading will refresh unbound properties
|
||||
|
@ -189,7 +193,8 @@ Discourse = Ember.Application.createWithMixins({
|
|||
|
||||
/**
|
||||
Our own $.ajax method. Makes sure the .then method executes in an Ember runloop
|
||||
for performance reasons.
|
||||
for performance reasons. Also automatically adjusts the URL to support installs
|
||||
in subfolders.
|
||||
|
||||
@method ajax
|
||||
**/
|
||||
|
@ -211,13 +216,27 @@ Discourse = Ember.Application.createWithMixins({
|
|||
}
|
||||
|
||||
if (args.success) {
|
||||
console.log("DEPRECATION: Discourse.ajax should use promises, received 'success' callback");
|
||||
console.warning("DEPRECATION: Discourse.ajax should use promises, received 'success' callback");
|
||||
}
|
||||
if (args.error) {
|
||||
console.log("DEPRECATION: Discourse.ajax should use promises, received 'error' callback");
|
||||
console.warning("DEPRECATION: Discourse.ajax should use promises, received 'error' callback");
|
||||
}
|
||||
|
||||
return $.ajax(url, args);
|
||||
return Ember.Deferred.promise(function (promise) {
|
||||
var oldSuccess = args.success;
|
||||
args.success = function(xhr) {
|
||||
Ember.run(promise, promise.resolve, xhr);
|
||||
if (oldSuccess) oldSuccess(xhr);
|
||||
}
|
||||
|
||||
var oldError = args.error;
|
||||
args.error = function(xhr) {
|
||||
promise.reject(xhr);
|
||||
if (oldError) oldError(xhr);
|
||||
}
|
||||
|
||||
$.ajax(Discourse.getURL(url), args);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,7 +72,7 @@ Discourse.ClickTrack = {
|
|||
|
||||
// if they want to open in a new tab, do an AJAX request
|
||||
if (e.shiftKey || e.metaKey || e.ctrlKey || e.which === 2) {
|
||||
Discourse.ajax(Discourse.getURL("/clicks/track"), {
|
||||
Discourse.ajax("/clicks/track", {
|
||||
data: {
|
||||
url: href,
|
||||
post_id: postId,
|
||||
|
@ -86,7 +86,7 @@ Discourse.ClickTrack = {
|
|||
|
||||
// If we're on the same site, use the router and track via AJAX
|
||||
if (href.indexOf(Discourse.URL.origin()) === 0) {
|
||||
Discourse.ajax(Discourse.getURL("/clicks/track"), {
|
||||
Discourse.ajax("/clicks/track", {
|
||||
data: {
|
||||
url: href,
|
||||
post_id: postId,
|
||||
|
|
|
@ -22,7 +22,7 @@ Discourse.Mention = (function() {
|
|||
callback(cached);
|
||||
return false;
|
||||
} else {
|
||||
Discourse.ajax(Discourse.getURL("/users/is_local_username"), { data: { username: name } }).then(function(r) {
|
||||
Discourse.ajax("/users/is_local_username", { data: { username: name } }).then(function(r) {
|
||||
cache(name, r.valid);
|
||||
callback(r.valid);
|
||||
});
|
||||
|
|
|
@ -49,9 +49,7 @@ Discourse.Onebox = {
|
|||
$elem.addClass('loading-onebox');
|
||||
|
||||
// Retrieve the onebox
|
||||
var promise = Discourse.ajax(Discourse.getURL("/onebox"), {
|
||||
data: { url: url, refresh: refresh }
|
||||
});
|
||||
var promise = Discourse.ajax("/onebox", { data: { url: url, refresh: refresh } });
|
||||
|
||||
// We can call this when loading is complete
|
||||
var loadingFinished = function() {
|
||||
|
|
|
@ -98,7 +98,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
|||
highestSeenByTopic[topicId] = highestSeen;
|
||||
}
|
||||
if (!Object.isEmpty(newTimings)) {
|
||||
Discourse.ajax(Discourse.getURL('/topics/timings'), {
|
||||
Discourse.ajax('/topics/timings', {
|
||||
data: {
|
||||
timings: newTimings,
|
||||
topic_time: this.topicTime,
|
||||
|
|
|
@ -128,7 +128,7 @@ Discourse.URL = {
|
|||
@method redirectTo
|
||||
**/
|
||||
redirectTo: function(url) {
|
||||
window.location = url;
|
||||
window.location = Discourse.getURL(url);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ var cacheTopicId = null;
|
|||
var cacheTime = null;
|
||||
|
||||
var debouncedSearch = Discourse.debouncePromise(function(term, topicId) {
|
||||
return Discourse.ajax(Discourse.getURL('/users/search/users'), {
|
||||
return Discourse.ajax('/users/search/users', {
|
||||
data: {
|
||||
term: term,
|
||||
topic_id: topicId
|
||||
|
|
|
@ -44,15 +44,10 @@ Discourse.Utilities = {
|
|||
},
|
||||
|
||||
avatarUrl: function(username, size, template) {
|
||||
var rawSize;
|
||||
if (!username) {
|
||||
return "";
|
||||
}
|
||||
if (!username) return "";
|
||||
size = Discourse.Utilities.translateSize(size);
|
||||
rawSize = (size * (window.devicePixelRatio || 1)).toFixed();
|
||||
if (template) {
|
||||
return template.replace(/\{size\}/g, rawSize);
|
||||
}
|
||||
var rawSize = (size * (window.devicePixelRatio || 1)).toFixed();
|
||||
if (template) return template.replace(/\{size\}/g, rawSize);
|
||||
return Discourse.getURL("/users/") + (username.toLowerCase()) + "/avatar/" + rawSize + "?__ws=" + (encodeURIComponent(Discourse.BaseUrl || ""));
|
||||
},
|
||||
|
||||
|
@ -71,8 +66,7 @@ Discourse.Utilities = {
|
|||
},
|
||||
|
||||
postUrl: function(slug, topicId, postNumber) {
|
||||
var url;
|
||||
url = Discourse.getURL("/t/");
|
||||
var url = Discourse.getURL("/t/");
|
||||
if (slug) {
|
||||
url += slug + "/";
|
||||
} else {
|
||||
|
|
|
@ -132,7 +132,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||
// If visible update the text
|
||||
var educationKey = this.get('content.creatingTopic') ? 'new-topic' : 'new-reply';
|
||||
var composerController = this;
|
||||
Discourse.ajax(Discourse.getURL("/education/") + educationKey).then(function(result) {
|
||||
Discourse.ajax("/education/" + educationKey).then(function(result) {
|
||||
composerController.set('educationContents', result);
|
||||
});
|
||||
}.observes('typedReply', 'content.creatingTopic', 'Discourse.currentUser.reply_count'),
|
||||
|
|
|
@ -29,16 +29,16 @@ Discourse.PreferencesUsernameController = Discourse.ObjectController.extend({
|
|||
if( this.get('newUsername') && this.get('newUsername').length < 3 ) {
|
||||
this.set('errorMessage', Em.String.i18n('user.name.too_short'));
|
||||
} else {
|
||||
var _this = this;
|
||||
var preferencesUsernameController = this;
|
||||
this.set('taken', false);
|
||||
this.set('errorMessage', null);
|
||||
if (this.blank('newUsername')) return;
|
||||
if (this.get('unchanged')) return;
|
||||
Discourse.User.checkUsername(this.get('newUsername')).then(function(result) {
|
||||
if (result.errors) {
|
||||
return _this.set('errorMessage', result.errors.join(' '));
|
||||
preferencesUsernameController.set('errorMessage', result.errors.join(' '));
|
||||
} else if (result.available === false) {
|
||||
return _this.set('taken', true);
|
||||
preferencesUsernameController.set('taken', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -50,17 +50,16 @@ Discourse.PreferencesUsernameController = Discourse.ObjectController.extend({
|
|||
}).property('saving'),
|
||||
|
||||
changeUsername: function() {
|
||||
var _this = this;
|
||||
var preferencesUsernameController = this;
|
||||
return bootbox.confirm(Em.String.i18n("user.change_username.confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
|
||||
if (result) {
|
||||
_this.set('saving', true);
|
||||
return _this.get('content').changeUsername(_this.get('newUsername')).then(function() {
|
||||
var url = Discourse.getURL("/users/") + _this.get('newUsername').toLowerCase() + "/preferences";
|
||||
Discourse.URL.redirectTo(url);
|
||||
preferencesUsernameController.set('saving', true);
|
||||
preferencesUsernameController.get('content').changeUsername(preferencesUsernameController.get('newUsername')).then(function() {
|
||||
Discourse.URL.redirectTo("/users/" + preferencesUsernameController.get('newUsername').toLowerCase() + "/preferences");
|
||||
}, function() {
|
||||
// error
|
||||
_this.set('error', true);
|
||||
_this.set('saving', false);
|
||||
preferencesUsernameController.set('error', true);
|
||||
preferencesUsernameController.set('saving', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ Discourse.StaticController = Discourse.Controller.extend({
|
|||
text = text[1];
|
||||
this.set('content', text);
|
||||
} else {
|
||||
return Discourse.ajax(Discourse.getURL(path + ".json")).then(function (result) {
|
||||
return Discourse.ajax(path + ".json").then(function (result) {
|
||||
staticController.set('content', result);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
// Create our post action
|
||||
var actionSummary = this;
|
||||
|
||||
return Discourse.ajax(Discourse.getURL("/post_actions"), {
|
||||
return Discourse.ajax("/post_actions", {
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: this.get('post.id'),
|
||||
|
@ -77,7 +77,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
this.removeAction();
|
||||
|
||||
// Remove our post action
|
||||
return Discourse.ajax(Discourse.getURL("/post_actions/") + (this.get('post.id')), {
|
||||
return Discourse.ajax("/post_actions/" + (this.get('post.id')), {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
post_action_type_id: this.get('id')
|
||||
|
@ -87,7 +87,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
|
||||
clearFlags: function() {
|
||||
var actionSummary = this;
|
||||
return Discourse.ajax(Discourse.getURL("/post_actions/clear_flags"), {
|
||||
return Discourse.ajax("/post_actions/clear_flags", {
|
||||
type: "POST",
|
||||
data: {
|
||||
post_action_type_id: this.get('id'),
|
||||
|
@ -101,7 +101,7 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
|||
|
||||
loadUsers: function() {
|
||||
var actionSummary = this;
|
||||
Discourse.ajax(Discourse.getURL("/post_actions/users"), {
|
||||
Discourse.ajax("/post_actions/users", {
|
||||
data: {
|
||||
id: this.get('post.id'),
|
||||
post_action_type_id: this.get('id')
|
||||
|
|
|
@ -30,9 +30,9 @@ Discourse.Category = Discourse.Model.extend({
|
|||
}.property('topic_count'),
|
||||
|
||||
save: function(args) {
|
||||
var url = Discourse.getURL("/categories");
|
||||
var url = "/categories";
|
||||
if (this.get('id')) {
|
||||
url = Discourse.getURL("/categories/") + (this.get('id'));
|
||||
url = "/categories/" + (this.get('id'));
|
||||
}
|
||||
|
||||
return Discourse.ajax(url, {
|
||||
|
@ -47,14 +47,14 @@ Discourse.Category = Discourse.Model.extend({
|
|||
},
|
||||
|
||||
destroy: function(callback) {
|
||||
return Discourse.ajax(Discourse.getURL("/categories/") + (this.get('slug') || this.get('id')), { type: 'DELETE' });
|
||||
return Discourse.ajax("/categories/" + (this.get('slug') || this.get('id')), { type: 'DELETE' });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Discourse.Category.reopenClass({
|
||||
findBySlugOrId: function(slugOrId) {
|
||||
return Discourse.ajax(Discourse.getURL("/categories/") + slugOrId + ".json").then(function (result) {
|
||||
return Discourse.ajax("/categories/" + slugOrId + ".json").then(function (result) {
|
||||
return Discourse.Category.create(result.category);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ Discourse.CategoryList.reopenClass({
|
|||
list: function(filter) {
|
||||
var route = this;
|
||||
|
||||
return Discourse.ajax(Discourse.getURL("/") + filter + ".json").then(function(result) {
|
||||
return Discourse.ajax("/" + filter + ".json").then(function(result) {
|
||||
var categoryList = Discourse.TopicList.create();
|
||||
categoryList.set('can_create_category', result.category_list.can_create_category);
|
||||
categoryList.set('categories', route.categoriesFrom(result));
|
||||
|
|
|
@ -11,7 +11,7 @@ Discourse.Draft = Discourse.Model.extend({});
|
|||
Discourse.Draft.reopenClass({
|
||||
|
||||
clear: function(key, sequence) {
|
||||
return Discourse.ajax(Discourse.getURL("/draft"), {
|
||||
return Discourse.ajax("/draft", {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
draft_key: key,
|
||||
|
@ -21,7 +21,7 @@ Discourse.Draft.reopenClass({
|
|||
},
|
||||
|
||||
get: function(key) {
|
||||
return Discourse.ajax(Discourse.getURL('/draft'), {
|
||||
return Discourse.ajax('/draft', {
|
||||
data: { draft_key: key },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
@ -34,7 +34,7 @@ Discourse.Draft.reopenClass({
|
|||
|
||||
save: function(key, sequence, data) {
|
||||
data = typeof data === "string" ? data : JSON.stringify(data);
|
||||
return Discourse.ajax(Discourse.getURL("/draft"), {
|
||||
return Discourse.ajax("/draft", {
|
||||
type: 'POST',
|
||||
data: {
|
||||
draft_key: key,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
Discourse.Invite = Discourse.Model.extend({
|
||||
|
||||
rescind: function() {
|
||||
Discourse.ajax(Discourse.getURL('/invites'), {
|
||||
Discourse.ajax('/invites', {
|
||||
type: 'DELETE',
|
||||
data: { email: this.get('email') }
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ Discourse.InviteList = Discourse.Model.extend({
|
|||
Discourse.InviteList.reopenClass({
|
||||
|
||||
findInvitedBy: function(user) {
|
||||
return Discourse.ajax({ url: Discourse.getURL("/users/") + (user.get('username_lower')) + "/invited.json" }).then(function (result) {
|
||||
return Discourse.ajax("/users/" + (user.get('username_lower')) + "/invited.json").then(function (result) {
|
||||
var invitedList = result.invited_list;
|
||||
if (invitedList.pending) {
|
||||
invitedList.pending = invitedList.pending.map(function(i) {
|
||||
|
|
|
@ -39,17 +39,6 @@ Discourse.Model = Ember.Object.extend(Discourse.Presence, {
|
|||
|
||||
Discourse.Model.reopenClass({
|
||||
|
||||
/**
|
||||
$.get shortcut that uses Discourse.Url and returns a promise
|
||||
**/
|
||||
getModelAjax: function(url) {
|
||||
var modelClass = this;
|
||||
return Discourse.ajax(url, { cache: false }).then(function (result) {
|
||||
return modelClass.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
Given an array of values, return them in a hash
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
**/
|
||||
Discourse.Post = Discourse.Model.extend({
|
||||
|
||||
shareUrl: function(){
|
||||
shareUrl: function() {
|
||||
var user = Discourse.get('currentUser');
|
||||
if (this.get('postnumber') === 1){
|
||||
return this.get('topic.url');
|
||||
|
@ -17,9 +17,9 @@ Discourse.Post = Discourse.Model.extend({
|
|||
}
|
||||
}.property('url'),
|
||||
|
||||
new_user:(function(){
|
||||
new_user: function() {
|
||||
return this.get('trust_level') === 0;
|
||||
}).property('trust_level'),
|
||||
}.property('trust_level'),
|
||||
|
||||
url: function() {
|
||||
return Discourse.Utilities.postUrl(this.get('topic.slug') || this.get('topic_slug'), this.get('topic_id'), this.get('post_number'));
|
||||
|
@ -29,34 +29,34 @@ Discourse.Post = Discourse.Model.extend({
|
|||
return Discourse.getURL("/t/") + (this.get('topic_id')) + "/" + (this.get('reply_to_post_number'));
|
||||
}.property('reply_to_post_number'),
|
||||
|
||||
usernameUrl: (function() {
|
||||
usernameUrl: function() {
|
||||
return Discourse.getURL("/users/" + this.get('username'));
|
||||
}).property('username'),
|
||||
}.property('username'),
|
||||
|
||||
showUserReplyTab: (function() {
|
||||
showUserReplyTab: function() {
|
||||
return this.get('reply_to_user') && (this.get('reply_to_post_number') < (this.get('post_number') - 1));
|
||||
}).property('reply_to_user', 'reply_to_post_number', 'post_number'),
|
||||
}.property('reply_to_user', 'reply_to_post_number', 'post_number'),
|
||||
|
||||
firstPost: (function() {
|
||||
firstPost: function() {
|
||||
if (this.get('bestOfFirst') === true) return true;
|
||||
return this.get('post_number') === 1;
|
||||
}).property('post_number'),
|
||||
}.property('post_number'),
|
||||
|
||||
byTopicCreator: function() {
|
||||
return this.get('topic.created_by.id') === this.get('user_id');
|
||||
}.property('topic.created_by.id', 'user_id'),
|
||||
|
||||
hasHistory: (function() {
|
||||
hasHistory: function() {
|
||||
return this.get('version') > 1;
|
||||
}).property('version'),
|
||||
}.property('version'),
|
||||
|
||||
postElementId: (function() {
|
||||
postElementId: function() {
|
||||
return "post_" + (this.get('post_number'));
|
||||
}).property(),
|
||||
}.property(),
|
||||
|
||||
// The class for the read icon of the post. It starts with read-icon then adds 'seen' or
|
||||
// 'last-read' if the post has been seen or is the highest post number seen so far respectively.
|
||||
bookmarkClass: (function() {
|
||||
bookmarkClass: function() {
|
||||
var result, topic;
|
||||
result = 'read-icon';
|
||||
if (this.get('bookmarked')) return result + ' bookmarked';
|
||||
|
@ -69,7 +69,7 @@ Discourse.Post = Discourse.Model.extend({
|
|||
}
|
||||
}
|
||||
return result;
|
||||
}).property('read', 'topic.last_read_post_number', 'bookmarked'),
|
||||
}.property('read', 'topic.last_read_post_number', 'bookmarked'),
|
||||
|
||||
// Custom tooltips for the bookmark icons
|
||||
bookmarkTooltip: (function() {
|
||||
|
@ -85,13 +85,12 @@ Discourse.Post = Discourse.Model.extend({
|
|||
|
||||
bookmarkedChanged: function() {
|
||||
var post = this;
|
||||
Discourse.ajax({
|
||||
url: Discourse.getURL("/posts/") + (this.get('id')) + "/bookmark",
|
||||
Discourse.ajax("/posts/" + (this.get('id')) + "/bookmark", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
bookmarked: this.get('bookmarked') ? true : false
|
||||
}
|
||||
}).fail(function (error) {
|
||||
}).then(null, function (error) {
|
||||
if (error && error.responseText) {
|
||||
bootbox.alert($.parseJSON(error.responseText).errors[0]);
|
||||
} else {
|
||||
|
@ -101,17 +100,17 @@ Discourse.Post = Discourse.Model.extend({
|
|||
|
||||
}.observes('bookmarked'),
|
||||
|
||||
internalLinks: (function() {
|
||||
internalLinks: function() {
|
||||
if (this.blank('link_counts')) return null;
|
||||
return this.get('link_counts').filterProperty('internal').filterProperty('title');
|
||||
}).property('link_counts.@each.internal'),
|
||||
}.property('link_counts.@each.internal'),
|
||||
|
||||
// Edits are the version - 1, so version 2 = 1 edit
|
||||
editCount: (function() {
|
||||
editCount: function() {
|
||||
return this.get('version') - 1;
|
||||
}).property('version'),
|
||||
}.property('version'),
|
||||
|
||||
historyHeat: (function() {
|
||||
historyHeat: function() {
|
||||
var rightNow, updatedAt, updatedAtDate;
|
||||
if (!(updatedAt = this.get('updated_at'))) return;
|
||||
rightNow = new Date().getTime();
|
||||
|
@ -121,17 +120,17 @@ Discourse.Post = Discourse.Model.extend({
|
|||
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 12)) return 'heatmap-high';
|
||||
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 24)) return 'heatmap-med';
|
||||
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 48)) return 'heatmap-low';
|
||||
}).property('updated_at'),
|
||||
}.property('updated_at'),
|
||||
|
||||
flagsAvailable: (function() {
|
||||
flagsAvailable: function() {
|
||||
var _this = this;
|
||||
var flags = Discourse.get('site.flagTypes').filter(function(item) {
|
||||
return _this.get("actionByName." + (item.get('name_key')) + ".can_act");
|
||||
});
|
||||
return flags;
|
||||
}).property('Discourse.site.flagTypes', 'actions_summary.@each.can_act'),
|
||||
}.property('Discourse.site.flagTypes', 'actions_summary.@each.can_act'),
|
||||
|
||||
actionsHistory: (function() {
|
||||
actionsHistory: function() {
|
||||
if (!this.present('actions_summary')) return null;
|
||||
|
||||
return this.get('actions_summary').filter(function(i) {
|
||||
|
@ -139,15 +138,14 @@ Discourse.Post = Discourse.Model.extend({
|
|||
if (i.get('users') && i.get('users').length > 0) return true;
|
||||
return !i.get('hidden');
|
||||
});
|
||||
}).property('actions_summary.@each.users', 'actions_summary.@each.count'),
|
||||
}.property('actions_summary.@each.users', 'actions_summary.@each.count'),
|
||||
|
||||
// Save a post and call the callback when done.
|
||||
save: function(complete, error) {
|
||||
var data, metaData;
|
||||
if (!this.get('newPost')) {
|
||||
// We're updating a post
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/posts/") + (this.get('id')),
|
||||
return Discourse.ajax("/posts/" + (this.get('id')), {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
post: { raw: this.get('raw') },
|
||||
|
@ -178,9 +176,8 @@ Discourse.Post = Discourse.Model.extend({
|
|||
data.meta_data = {};
|
||||
Ember.keys(metaData).forEach(function(key) { data.meta_data[key] = metaData.get(key); });
|
||||
}
|
||||
return Discourse.ajax({
|
||||
return Discourse.ajax("/posts", {
|
||||
type: 'POST',
|
||||
url: Discourse.getURL("/posts"),
|
||||
data: data
|
||||
}).then(function(result) {
|
||||
// Post created
|
||||
|
@ -193,11 +190,11 @@ Discourse.Post = Discourse.Model.extend({
|
|||
},
|
||||
|
||||
recover: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/posts/") + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
||||
return Discourse.ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
||||
},
|
||||
|
||||
destroy: function(complete) {
|
||||
return Discourse.ajax(Discourse.getURL("/posts/") + (this.get('id')), { type: 'DELETE' });
|
||||
return Discourse.ajax("/posts/" + (this.get('id')), { type: 'DELETE' });
|
||||
},
|
||||
|
||||
// Update the properties of this post from an obj, ignoring cooked as we should already
|
||||
|
@ -237,7 +234,7 @@ Discourse.Post = Discourse.Model.extend({
|
|||
this.set('replies', []);
|
||||
|
||||
var parent = this;
|
||||
return Discourse.ajax({url: Discourse.getURL("/posts/") + (this.get('id')) + "/replies"}).then(function(loaded) {
|
||||
return Discourse.ajax("/posts/" + (this.get('id')) + "/replies").then(function(loaded) {
|
||||
var replies = parent.get('replies');
|
||||
loaded.each(function(reply) {
|
||||
var post = Discourse.Post.create(reply);
|
||||
|
@ -249,7 +246,7 @@ Discourse.Post = Discourse.Model.extend({
|
|||
},
|
||||
|
||||
loadVersions: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/posts/") + (this.get('id')) + "/versions.json");
|
||||
return Discourse.ajax("/posts/" + (this.get('id')) + "/versions.json");
|
||||
},
|
||||
|
||||
// Whether to show replies directly below
|
||||
|
@ -303,7 +300,7 @@ Discourse.Post.reopenClass({
|
|||
},
|
||||
|
||||
deleteMany: function(posts) {
|
||||
return Discourse.ajax(Discourse.getURL("/posts/destroy_many"), {
|
||||
return Discourse.ajax("/posts/destroy_many", {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
post_ids: posts.map(function(p) { return p.get('id'); })
|
||||
|
@ -312,26 +309,26 @@ Discourse.Post.reopenClass({
|
|||
},
|
||||
|
||||
loadVersion: function(postId, version, callback) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/posts/") + postId + ".json?version=" + version}).then(function(result) {
|
||||
return Discourse.ajax("/posts/" + postId + ".json?version=" + version).then(function(result) {
|
||||
return Discourse.Post.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
loadByPostNumber: function(topicId, postId) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/posts/by_number/") + topicId + "/" + postId + ".json"}).then(function (result) {
|
||||
return Discourse.ajax("/posts/by_number/" + topicId + "/" + postId + ".json").then(function (result) {
|
||||
return Discourse.Post.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
loadQuote: function(postId) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/posts/") + postId + ".json"}).then(function(result) {
|
||||
return Discourse.ajax("/posts/" + postId + ".json").then(function(result) {
|
||||
var post = Discourse.Post.create(result);
|
||||
return Discourse.BBCode.buildQuoteBBCode(post, post.get('raw'));
|
||||
});
|
||||
},
|
||||
|
||||
load: function(postId) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/posts/") + postId + ".json"}).then(function (result) {
|
||||
return Discourse.ajax("/posts/" + postId + ".json").then(function (result) {
|
||||
return Discourse.Post.create(result);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
url: "" + (this.get('url')) + "/star",
|
||||
type: 'PUT',
|
||||
data: { starred: topic.get('starred') ? true : false }
|
||||
}).fail(function (error) {
|
||||
}).then(null, function (error) {
|
||||
topic.toggleProperty('starred');
|
||||
|
||||
if (error && error.responseText) {
|
||||
|
@ -185,25 +185,22 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
|
||||
// Reset our read data for this topic
|
||||
resetRead: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/t/") + (this.get('id')) + "/timings", {
|
||||
return Discourse.ajax("/t/" + (this.get('id')) + "/timings", {
|
||||
type: 'DELETE'
|
||||
});
|
||||
},
|
||||
|
||||
// Invite a user to this topic
|
||||
inviteUser: function(user) {
|
||||
return Discourse.ajax({
|
||||
return Discourse.ajax("/t/" + (this.get('id')) + "/invite", {
|
||||
type: 'POST',
|
||||
url: Discourse.getURL("/t/") + (this.get('id')) + "/invite",
|
||||
data: {
|
||||
user: user
|
||||
}
|
||||
data: { user: user }
|
||||
});
|
||||
},
|
||||
|
||||
// Delete this topic
|
||||
destroy: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/t/") + (this.get('id')), { type: 'DELETE' });
|
||||
return Discourse.ajax("/t/" + (this.get('id')), { type: 'DELETE' });
|
||||
},
|
||||
|
||||
// Load the posts for this topic
|
||||
|
@ -315,12 +312,9 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
updateNotifications: function(v) {
|
||||
this.set('notification_level', v);
|
||||
this.set('notifications_reason_id', null);
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/t/") + (this.get('id')) + "/notifications",
|
||||
return Discourse.ajax("/t/" + (this.get('id')) + "/notifications", {
|
||||
type: 'POST',
|
||||
data: {
|
||||
notification_level: v
|
||||
}
|
||||
data: { notification_level: v }
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -351,9 +345,9 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
// Clear the pin optimistically from the object
|
||||
topic.set('pinned', false);
|
||||
|
||||
Discourse.ajax(Discourse.getURL("/t/") + this.get('id') + "/clear-pin", {
|
||||
Discourse.ajax("/t/" + this.get('id') + "/clear-pin", {
|
||||
type: 'PUT'
|
||||
}).fail(function() {
|
||||
}).then(null, function() {
|
||||
// On error, put the pin back
|
||||
topic.set('pinned', true);
|
||||
});
|
||||
|
@ -403,7 +397,7 @@ Discourse.Topic.reopenClass({
|
|||
@returns A promise that will resolve to the topics
|
||||
**/
|
||||
findSimilarTo: function(title, body) {
|
||||
return Discourse.ajax({url: Discourse.getURL("/topics/similar_to"), data: {title: title, raw: body} }).then(function (results) {
|
||||
return Discourse.ajax("/topics/similar_to", { data: {title: title, raw: body} }).then(function (results) {
|
||||
return results.map(function(topic) { return Discourse.Topic.create(topic) });
|
||||
});
|
||||
},
|
||||
|
@ -457,7 +451,7 @@ Discourse.Topic.reopenClass({
|
|||
|
||||
// Create a topic from posts
|
||||
movePosts: function(topicId, title, postIds) {
|
||||
return Discourse.ajax(Discourse.getURL(Discourse.getURL("/t/")) + topicId + "/move-posts", {
|
||||
return Discourse.ajax("/t/" + topicId + "/move-posts", {
|
||||
type: 'POST',
|
||||
data: { title: title, post_ids: postIds }
|
||||
});
|
||||
|
|
|
@ -61,9 +61,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@property path
|
||||
@type {String}
|
||||
**/
|
||||
path: (function() {
|
||||
path: function() {
|
||||
return Discourse.getURL("/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
}.property('username'),
|
||||
|
||||
/**
|
||||
Path to this user's administration
|
||||
|
@ -71,9 +71,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@property adminPath
|
||||
@type {String}
|
||||
**/
|
||||
adminPath: (function() {
|
||||
adminPath: function() {
|
||||
return Discourse.getURL("/admin/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
}.property('username'),
|
||||
|
||||
/**
|
||||
This user's username in lowercase.
|
||||
|
@ -81,9 +81,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@property username_lower
|
||||
@type {String}
|
||||
**/
|
||||
username_lower: (function() {
|
||||
username_lower: function() {
|
||||
return this.get('username').toLowerCase();
|
||||
}).property('username'),
|
||||
}.property('username'),
|
||||
|
||||
/**
|
||||
This user's trust level.
|
||||
|
@ -91,9 +91,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@property trustLevel
|
||||
@type {Integer}
|
||||
**/
|
||||
trustLevel: (function() {
|
||||
trustLevel: function() {
|
||||
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
|
||||
}).property('trust_level'),
|
||||
}.property('trust_level'),
|
||||
|
||||
/**
|
||||
Changes this user's username.
|
||||
|
@ -103,12 +103,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@returns Result of ajax call
|
||||
**/
|
||||
changeUsername: function(newUsername) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/users/") + (this.get('username_lower')) + "/preferences/username",
|
||||
return Discourse.ajax("/users/" + (this.get('username_lower')) + "/preferences/username", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
new_username: newUsername
|
||||
}
|
||||
data: { new_username: newUsername }
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -120,12 +117,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@returns Result of ajax call
|
||||
**/
|
||||
changeEmail: function(email) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/users/") + (this.get('username_lower')) + "/preferences/email",
|
||||
return Discourse.ajax("/users/" + (this.get('username_lower')) + "/preferences/email", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
email: email
|
||||
}
|
||||
data: { email: email }
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -147,7 +141,7 @@ Discourse.User = Discourse.Model.extend({
|
|||
**/
|
||||
save: function() {
|
||||
var user = this;
|
||||
return Discourse.ajax(Discourse.getURL("/users/") + this.get('username').toLowerCase(), {
|
||||
return Discourse.ajax("/users/" + this.get('username').toLowerCase(), {
|
||||
data: this.getProperties('auto_track_topics_after_msecs',
|
||||
'bio_raw',
|
||||
'website',
|
||||
|
@ -174,7 +168,7 @@ Discourse.User = Discourse.Model.extend({
|
|||
@returns {Promise} the result of the change password operation
|
||||
**/
|
||||
changePassword: function() {
|
||||
return Discourse.ajax(Discourse.getURL("/session/forgot_password"), {
|
||||
return Discourse.ajax("/session/forgot_password", {
|
||||
dataType: 'json',
|
||||
data: {
|
||||
login: this.get('username')
|
||||
|
@ -209,13 +203,8 @@ Discourse.User = Discourse.Model.extend({
|
|||
loadUserAction: function(id) {
|
||||
var user = this;
|
||||
var stream = this.get('stream');
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/user_actions/") + id + ".json",
|
||||
dataType: 'json',
|
||||
cache: 'false'
|
||||
}).then(function(result) {
|
||||
return Discourse.ajax("/user_actions/" + id + ".json", { cache: 'false' }).then(function(result) {
|
||||
if (result) {
|
||||
|
||||
if ((user.get('streamFilter') || result.action_type) !== result.action_type) return;
|
||||
|
||||
var action = Em.A();
|
||||
|
@ -374,7 +363,7 @@ Discourse.User = Discourse.Model.extend({
|
|||
var user = this;
|
||||
var username = this.get('username');
|
||||
PreloadStore.getAndRemove("user_" + username, function() {
|
||||
return Discourse.ajax({ url: Discourse.getURL("/users/") + username + '.json' });
|
||||
return Discourse.ajax("/users/" + username + '.json');
|
||||
}).then(function (json) {
|
||||
// Create a user from the resulting JSON
|
||||
json.user.stats = Discourse.User.groupStats(json.user.stats.map(function(s) {
|
||||
|
@ -410,13 +399,8 @@ Discourse.User.reopenClass({
|
|||
@param {String} email An email address to check
|
||||
**/
|
||||
checkUsername: function(username, email) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL('/users/check_username'),
|
||||
type: 'GET',
|
||||
data: {
|
||||
username: username,
|
||||
email: email
|
||||
}
|
||||
return Discourse.ajax('/users/check_username', {
|
||||
data: { username: username, email: email }
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -477,9 +461,7 @@ Discourse.User.reopenClass({
|
|||
@returns Result of ajax call
|
||||
**/
|
||||
createAccount: function(name, email, password, username, passwordConfirm, challenge) {
|
||||
return Discourse.ajax({
|
||||
url: Discourse.getURL("/users"),
|
||||
dataType: 'json',
|
||||
return Discourse.ajax("/users", {
|
||||
data: {
|
||||
name: name,
|
||||
email: email,
|
||||
|
|
|
@ -54,7 +54,7 @@ Discourse.HeaderView = Discourse.View.extend({
|
|||
showNotifications: function() {
|
||||
|
||||
var headerView = this;
|
||||
Discourse.ajax(Discourse.getURL('/notifications')).then(function(result) {
|
||||
Discourse.ajax('/notifications').then(function(result) {
|
||||
headerView.set('notifications', result.map(function(n) {
|
||||
return Discourse.Notification.create(n);
|
||||
}));
|
||||
|
|
|
@ -242,7 +242,7 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
|
|||
|
||||
fetchConfirmationValue: function() {
|
||||
var createAccountView = this;
|
||||
return Discourse.ajax(Discourse.getURL('/users/hp.json')).then(function (json) {
|
||||
return Discourse.ajax('/users/hp.json').then(function (json) {
|
||||
createAccountView.set('accountPasswordConfirm', json.value);
|
||||
createAccountView.set('accountChallenge', json.challenge.split("").reverse().join(""));
|
||||
});
|
||||
|
|
|
@ -104,8 +104,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
|||
).then(function() {
|
||||
// success
|
||||
$('#discourse-modal').modal('hide');
|
||||
var url = Discourse.getURL("/category/") + categoryView.get('category.name');
|
||||
Discourse.URL.redirectTo(url);
|
||||
Discourse.URL.redirectTo("/category/" + categoryView.get('category.name'));
|
||||
}, function(errors) {
|
||||
// errors
|
||||
if(errors.length === 0) errors.push(Em.String.i18n("category.save_error"));
|
||||
|
@ -116,8 +115,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
|||
this.get('category').save().then(function(result) {
|
||||
// success
|
||||
$('#discourse-modal').modal('hide');
|
||||
var url = Discourse.getURL("/category/") + (Discourse.Utilities.categoryUrlId(result.category));
|
||||
Discourse.URL.redirectTo(url);
|
||||
Discourse.URL.redirectTo("/category/" + Discourse.Utilities.categoryUrlId(result.category));
|
||||
}, function(errors) {
|
||||
// errors
|
||||
if(errors.length === 0) errors.push(Em.String.i18n("category.creation_error"));
|
||||
|
@ -135,7 +133,7 @@ Discourse.EditCategoryView = Discourse.ModalBodyView.extend({
|
|||
if (result) {
|
||||
categoryView.get('category').destroy().then(function(){
|
||||
// success
|
||||
Discourse.URL.redirectTo(Discourse.getURL("/categories"));
|
||||
Discourse.URL.redirectTo("/categories");
|
||||
}, function(jqXHR){
|
||||
// error
|
||||
$('#discourse-modal').modal('show');
|
||||
|
|
|
@ -17,7 +17,7 @@ Discourse.ForgotPasswordView = Discourse.ModalBodyView.extend({
|
|||
|
||||
submit: function() {
|
||||
|
||||
Discourse.ajax(Discourse.getURL("/session/forgot_password"), {
|
||||
Discourse.ajax("/session/forgot_password", {
|
||||
data: { login: this.get('accountEmailOrUsername') },
|
||||
type: 'POST'
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
|||
this.set('loggingIn', true);
|
||||
|
||||
var loginView = this;
|
||||
Discourse.ajax(Discourse.getURL("/session"), {
|
||||
Discourse.ajax("/session", {
|
||||
data: { login: this.get('loginName'), password: this.get('loginPassword') },
|
||||
type: 'POST'
|
||||
}).then(function (result) {
|
||||
|
|
|
@ -12,7 +12,7 @@ Discourse.NotActivatedView = Discourse.ModalBodyView.extend({
|
|||
emailSent: false,
|
||||
|
||||
sendActivationEmail: function() {
|
||||
Discourse.ajax(Discourse.getURL('/users/') + this.get('username') + '/send_activation_email');
|
||||
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email');
|
||||
this.set('emailSent', true);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -146,7 +146,7 @@ Discourse.PostView = Discourse.View.extend({
|
|||
if ($aside.data('topic')) {
|
||||
topic_id = $aside.data('topic');
|
||||
}
|
||||
Discourse.ajax(Discourse.getURL("/posts/by_number/") + topic_id + "/" + ($aside.data('post'))).then(function (result) {
|
||||
Discourse.ajax("/posts/by_number/" + topic_id + "/" + ($aside.data('post'))).then(function (result) {
|
||||
var parsed = $(result.cooked);
|
||||
parsed.replaceText(originalText, "<span class='highlighted'>" + originalText + "</span>");
|
||||
$blockQuote.showHtml(parsed);
|
||||
|
|
|
@ -90,7 +90,7 @@ Discourse.SearchView = Discourse.View.extend({
|
|||
|
||||
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
|
||||
var searchView = this;
|
||||
return Discourse.ajax(Discourse.getURL('/search'), {
|
||||
return Discourse.ajax('/search', {
|
||||
data: {
|
||||
term: term,
|
||||
type_filter: typeFilter
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
onlogin: function(assertion) {
|
||||
if (readyCalled) {
|
||||
|
||||
Discourse.ajax({
|
||||
Discourse.ajax('/auth/persona/callback', {
|
||||
type: 'POST',
|
||||
url: Discourse.getURL('/auth/persona/callback'),
|
||||
data: { 'assertion': assertion },
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
Discourse.authenticationComplete(data);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class CreateAdminLogs < ActiveRecord::Migration
|
||||
def up
|
||||
create_table :admin_logs do |t|
|
||||
create_table :admin_logs, force: true do |t|
|
||||
t.integer :action, null: false
|
||||
t.integer :admin_id, null: false
|
||||
t.integer :target_user_id
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class CreateGroups < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :groups do |t|
|
||||
create_table :groups, force: true do |t|
|
||||
t.string :name, null: false
|
||||
t.timestamps
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class GroupUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :group_users do |t|
|
||||
create_table :group_users, force: true do |t|
|
||||
t.integer :group_id, null: false
|
||||
t.integer :user_id, null: false
|
||||
t.timestamps
|
||||
|
|
|
@ -2,7 +2,7 @@ class AddSecurityToCategories < ActiveRecord::Migration
|
|||
def change
|
||||
add_column :categories, :secure, :boolean, default: false, null: false
|
||||
|
||||
create_table :category_groups do |t|
|
||||
create_table :category_groups, force: true do |t|
|
||||
t.integer :category_id, null: false
|
||||
t.integer :group_id, null: false
|
||||
t.timestamps
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AddTopicAllowedGroups < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :topic_allowed_groups do |t|
|
||||
create_table :topic_allowed_groups, force: true do |t|
|
||||
# oops
|
||||
t.integer :group_id, :integer, null: false
|
||||
t.integer :topic_id, :integer, null: false
|
||||
|
|
Loading…
Reference in New Issue
Block a user