mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
parent
cc995e8ef6
commit
7919c15e56
@ -6,7 +6,8 @@ var EditorEditRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, bas
|
||||
model: function (params) {
|
||||
var self = this,
|
||||
post,
|
||||
postId;
|
||||
postId,
|
||||
paginationSettings;
|
||||
|
||||
postId = Number(params.post_id);
|
||||
|
||||
@ -20,18 +21,26 @@ var EditorEditRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, bas
|
||||
return post;
|
||||
}
|
||||
|
||||
return this.store.find('post', {
|
||||
id: params.post_id,
|
||||
paginationSettings = {
|
||||
id: postId,
|
||||
status: 'all',
|
||||
staticPages: 'all',
|
||||
}).then(function (records) {
|
||||
var post = records.get('firstObject');
|
||||
staticPages: 'all'
|
||||
};
|
||||
|
||||
if (post) {
|
||||
return post;
|
||||
return this.store.find('user', 'me').then(function (user) {
|
||||
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'],
|
||||
|
||||
model: function () {
|
||||
// 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 this.store.filter('post', paginationSettings, function () {
|
||||
return true;
|
||||
var self = this;
|
||||
|
||||
return this.store.find('user', 'me').then(function (user) {
|
||||
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) {
|
||||
var self = this,
|
||||
post,
|
||||
postId;
|
||||
postId,
|
||||
paginationSettings;
|
||||
|
||||
postId = Number(params.post_id);
|
||||
|
||||
@ -20,18 +21,26 @@ var PostsPostRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, load
|
||||
return post;
|
||||
}
|
||||
|
||||
return this.store.find('post', {
|
||||
id: params.post_id,
|
||||
paginationSettings = {
|
||||
id: postId,
|
||||
status: 'all',
|
||||
staticPages: 'all',
|
||||
}).then(function (records) {
|
||||
var post = records.get('firstObject');
|
||||
staticPages: 'all'
|
||||
};
|
||||
|
||||
if (post) {
|
||||
return post;
|
||||
return this.store.find('user', 'me').then(function (user) {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user