freedomofpress / securethenews

An automated scanner and web dashboard for tracking TLS deployment across news organizations
https://securethe.news
GNU Affero General Public License v3.0
102 stars 25 forks source link

BlogPosts published on the same day seem to be out of order #97

Closed garrettr closed 7 years ago

garrettr commented 7 years ago

Steps to Reproduce

  1. Publish a test blog post.
  2. Publish a second test blog post, with the same Publication date as the first post.
  3. View the blog post index (/blog)

Expected behavior

The second blog post, which was published after the first, should appear above the first blog post in the list of blog posts, since blogs typically display posts sorted from first to last posted.

Observed Behavior

The first blog post appears above the second blog post.

Additional Notes

This happens because we only store and sort by BlogPost date, which is a DateField, not a DateTimeField. There are at least two ways to fix this:

  1. Change the BlogPost.date DateField to a BlogPost.published DateTimeField. This might make entering the publication date a little more annoying in the admin, I'm not sure if the admin widget has ergonomic defaults.
  2. Additionally sort by another factor in addition to BlogPost.date, e.g. leverage the auto-incrementing primary key.