0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Post list: authors see their own posts

issue #3446
This commit is contained in:
Hannah Wolfe 2014-07-30 17:44:49 +01:00
parent 3ec5a5e978
commit 92ccdf7024
3 changed files with 47 additions and 22 deletions

View file

@ -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');
});
}); });
}, },

View file

@ -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;
});
}); });
}, },

View file

@ -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) {