mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
✨ support object id's (#390)
refs TryGhost/Ghost#7494 - remove id validation
This commit is contained in:
parent
a1707f3832
commit
2b0d0f841c
2 changed files with 12 additions and 33 deletions
|
@ -1,8 +1,6 @@
|
|||
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
||||
import base from 'ghost-admin/mixins/editor-base-route';
|
||||
import isNumber from 'ghost-admin/utils/isNumber';
|
||||
import isFinite from 'ghost-admin/utils/isFinite';
|
||||
|
||||
export default AuthenticatedRoute.extend(base, {
|
||||
titleToken: 'Editor',
|
||||
|
@ -14,20 +12,13 @@ export default AuthenticatedRoute.extend(base, {
|
|||
},
|
||||
|
||||
model(params) {
|
||||
let postId,
|
||||
query;
|
||||
|
||||
postId = Number(params.post_id);
|
||||
|
||||
if (!isNumber(postId) || !isFinite(postId) || postId % 1 !== 0 || postId <= 0) {
|
||||
return this.transitionTo('error404', `editor/${params.post_id}`);
|
||||
}
|
||||
|
||||
query = {
|
||||
id: postId,
|
||||
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
let query = {
|
||||
id: params.post_id,
|
||||
status: 'all',
|
||||
staticPages: 'all'
|
||||
};
|
||||
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
|
||||
return this.store.query('post', query).then((records) => {
|
||||
let post = records.get('firstObject');
|
||||
|
|
|
@ -1,32 +1,20 @@
|
|||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
||||
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
|
||||
import isNumber from 'ghost-admin/utils/isNumber';
|
||||
import isFinite from 'ghost-admin/utils/isFinite';
|
||||
|
||||
export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
||||
model(params) {
|
||||
let post,
|
||||
postId,
|
||||
query;
|
||||
|
||||
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
postId = Number(params.post_id);
|
||||
|
||||
if (!isNumber(postId) || !isFinite(postId) || postId % 1 !== 0 || postId <= 0) {
|
||||
return this.transitionTo('error404', params.post_id);
|
||||
}
|
||||
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
|
||||
post = this.store.peekRecord('post', postId);
|
||||
if (post) {
|
||||
return post;
|
||||
}
|
||||
|
||||
query = {
|
||||
id: postId,
|
||||
let post = this.store.peekRecord('post', params.post_id);
|
||||
let query = {
|
||||
id: params.post_id,
|
||||
status: 'all',
|
||||
staticPages: 'all'
|
||||
};
|
||||
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
||||
|
||||
if (post) {
|
||||
return post;
|
||||
}
|
||||
|
||||
return this.store.query('post', query).then((records) => {
|
||||
let post = records.get('firstObject');
|
||||
|
|
Loading…
Add table
Reference in a new issue