Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
✨ support object id's (#390)
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#7494

- remove id validation
  • Loading branch information
kirrg001 authored and kevinansfield committed Nov 14, 2016
1 parent 6d89e58 commit cd1fe4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
17 changes: 4 additions & 13 deletions app/routes/editor/edit.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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');
Expand Down
24 changes: 6 additions & 18 deletions app/routes/posts/post.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
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);
}
let post = this.store.peekRecord('post', params.post_id);
let query = {
id: params.post_id,
status: 'all',
staticPages: 'all'
};
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */

post = this.store.peekRecord('post', postId);
if (post) {
return post;
}

query = {
id: postId,
status: 'all',
staticPages: 'all'
};

return this.store.query('post', query).then((records) => {
let post = records.get('firstObject');

Expand Down

0 comments on commit cd1fe4a

Please sign in to comment.