Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get single post from API by id and query params; Auto-sort posts list #2884

Merged
merged 1 commit into from
Jun 17, 2014

Conversation

darvelo
Copy link
Contributor

@darvelo darvelo commented Jun 5, 2014

Get single post from API by id and query params; Auto-sort posts list

closes #2883, closes #2951

  • introduce custom findQuery in ApplicationAdapter
  • posts/post route and editor/edit route now use custom findQuery to find a single post by id with query params
  • create a sorting function in PostsController for out-of-order loading
  • refresh updated posts in posts.index to make PostsList highlight latest draft after returning from a save in editor

The only problem I had was after updating a draft.. going back to the PostsRoute highlighted the previously last-updated draft, not the most currently updated one. I had to modify PostsIndexRoute to grab a fresh list from the server, but that causes an extra request on first landing on /ghost/ember/.

@darvelo darvelo changed the title Auto-sorting of posts list; Allow getting posts/drafts from API [WIP] Auto-sorting of posts list; Allow getting posts/drafts from API Jun 5, 2014
@@ -77,6 +77,8 @@ posts = {
// only published posts if no user is present
if (!(options.context && options.context.user)) {
data.status = 'published';
} else {
data.status = data.status || 'all';

This comment was marked as abuse.

@ErisDS
Copy link
Member

ErisDS commented Jun 5, 2014

The API, by default, should only ever return published posts, this is fundamental logic for a blog and shouldn't be changed. That's why the tests are there.

This is also why we need @rjackson's fix from #2857 and why any of this is complicated at all. It is the job of the admin to make sure it asks for draft posts as well as published ones, as in the admin we are an authenticated user who has permission to view the drafts.

@darvelo
Copy link
Contributor Author

darvelo commented Jun 5, 2014

@ErisDS Ahh, I thought the user check might ensure that the user owned the posts, so sending a draft would be safe. Either way, the Ember-Data calls can be fixed up to query the main /posts API or check the store. I think the rest of the logic is okay barring that.

@ErisDS
Copy link
Member

ErisDS commented Jun 5, 2014

Yeah I think this is otherwise 👍

@ErisDS
Copy link
Member

ErisDS commented Jun 11, 2014

What's holding this back at present?

@darvelo
Copy link
Contributor Author

darvelo commented Jun 11, 2014

@ErisDS The Editor PR. :P I also want to ask a few questions to see how to proceed.

@ErisDS
Copy link
Member

ErisDS commented Jun 17, 2014

Can we get this in now? It needs a fix and a rebase etc but I think it's pretty much otherwise good to go?

@darvelo
Copy link
Contributor Author

darvelo commented Jun 17, 2014

@ErisDS I was going to tie the fix for #2951 into this but I can rebase for you to merge it now if you'd like a separate PR for that.

@ErisDS
Copy link
Member

ErisDS commented Jun 17, 2014

Whatever you prefer, I'm happy to get this in asap if you want?

closes TryGhost#2883, closes TryGhost#2951
- introduce custom findQuery in ApplicationAdapter
- posts/post route and editor/edit route now use custom findQuery to find a single post by id with query params
- create a sorting function in PostsController for out-of-order loading
- refresh updated posts in posts.index to make PostsList highlight latest draft after returning from a save in editor
@darvelo darvelo changed the title [WIP] Auto-sorting of posts list; Allow getting posts/drafts from API Get single post from API by id and query params; Auto-sort posts list Jun 17, 2014
@darvelo
Copy link
Contributor Author

darvelo commented Jun 17, 2014

@ErisDS This is ready.

ErisDS added a commit that referenced this pull request Jun 17, 2014
Get single post from API by id and query params; Auto-sort posts list
@ErisDS ErisDS merged commit 35f7d8a into TryGhost:master Jun 17, 2014
@darvelo darvelo deleted the sort-posts-list branch June 17, 2014 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ember Editor Route can't find posts with low IDs [Ember.js] Out-of-order loading of posts
2 participants