mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
parent
3ec5a5e978
commit
92ccdf7024
3 changed files with 47 additions and 22 deletions
|
@ -6,7 +6,8 @@ var EditorEditRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, bas
|
||||||
model: function (params) {
|
model: function (params) {
|
||||||
var self = this,
|
var self = this,
|
||||||
post,
|
post,
|
||||||
postId;
|
postId,
|
||||||
|
paginationSettings;
|
||||||
|
|
||||||
postId = Number(params.post_id);
|
postId = Number(params.post_id);
|
||||||
|
|
||||||
|
@ -20,18 +21,26 @@ var EditorEditRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, bas
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.store.find('post', {
|
paginationSettings = {
|
||||||
id: params.post_id,
|
id: postId,
|
||||||
status: 'all',
|
status: 'all',
|
||||||
staticPages: 'all',
|
staticPages: 'all'
|
||||||
}).then(function (records) {
|
};
|
||||||
var post = records.get('firstObject');
|
|
||||||
|
|
||||||
if (post) {
|
return this.store.find('user', 'me').then(function (user) {
|
||||||
return post;
|
if (user.get('isAuthor')) {
|
||||||
|
paginationSettings.author = user.get('slug');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.transitionTo('posts.index');
|
return self.store.find('post', paginationSettings).then(function (records) {
|
||||||
|
var post = records.get('firstObject');
|
||||||
|
|
||||||
|
if (post) {
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.transitionTo('posts.index');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,17 @@ var PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, Shortcut
|
||||||
classNames: ['manage'],
|
classNames: ['manage'],
|
||||||
|
|
||||||
model: function () {
|
model: function () {
|
||||||
// using `.filter` allows the template to auto-update when new models are pulled in from the server.
|
var self = this;
|
||||||
// we just need to 'return true' to allow all models by default.
|
|
||||||
return this.store.filter('post', paginationSettings, function () {
|
return this.store.find('user', 'me').then(function (user) {
|
||||||
return true;
|
if (user.get('isAuthor')) {
|
||||||
|
paginationSettings.author = user.get('slug');
|
||||||
|
}
|
||||||
|
// using `.filter` allows the template to auto-update when new models are pulled in from the server.
|
||||||
|
// we just need to 'return true' to allow all models by default.
|
||||||
|
return self.store.filter('post', paginationSettings, function () {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ var PostsPostRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, load
|
||||||
model: function (params) {
|
model: function (params) {
|
||||||
var self = this,
|
var self = this,
|
||||||
post,
|
post,
|
||||||
postId;
|
postId,
|
||||||
|
paginationSettings;
|
||||||
|
|
||||||
postId = Number(params.post_id);
|
postId = Number(params.post_id);
|
||||||
|
|
||||||
|
@ -20,18 +21,26 @@ var PostsPostRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, load
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.store.find('post', {
|
paginationSettings = {
|
||||||
id: params.post_id,
|
id: postId,
|
||||||
status: 'all',
|
status: 'all',
|
||||||
staticPages: 'all',
|
staticPages: 'all'
|
||||||
}).then(function (records) {
|
};
|
||||||
var post = records.get('firstObject');
|
|
||||||
|
|
||||||
if (post) {
|
return this.store.find('user', 'me').then(function (user) {
|
||||||
return post;
|
if (user.get('isAuthor')) {
|
||||||
|
paginationSettings.author = user.get('slug');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.transitionTo('posts.index');
|
return self.store.find('post', paginationSettings).then(function (records) {
|
||||||
|
var post = records.get('firstObject');
|
||||||
|
|
||||||
|
if (post) {
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.transitionTo('posts.index');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setupController: function (controller, model) {
|
setupController: function (controller, model) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue