Introduce common timestamp for sorting editions.

I want to be able to sort a mixture of publications *and* consultations
according to their primary timestamp. However, the primary timestamp for
publications is different than for any other edition types.

This change means that a copy of the relevant primary timestamp is saved
into the new `timestamp_for_sorting` column. This new column can then be
used for sorting the mixture of editions that I described above.

I did consider using the `COALESCE` MySQL function in the query instead
of introducing the extra column, but it appears that this would have
meant the query could no longer make use of indices for the timestamp
columns. Since performance on this page is already a concern, I decied
to go with the extra column as described above.
Use presenters for publications index page.

* I'm working towards being able to display both publications *and*
  consultations on this page. Using a presenter for each document will
  make it easier to have both a publication and a consultation provide
  all the necessary data to the view.
* Using `PublicationPresenter#display_date_microformat` instead of
  `ApplicationHelper#render_datetime_microformat` simplifies the view
  and will make it easier to have consultations provide a different
  timestamp.
* Decorating the document at the last possible moment in
  `DocumentFilter#each_document_with_index` was the simplest way I could
  get the Draper presenters to work sensibly. Initially I tried to use
  one of the forms where a collection of models is decorated at once,
  but I ran into problems with this where the `DocumentFilter#documents`
  collection is no longer an instance of  `ActiveRecord::Relation` and
  so things like pagination were breaking.
Display both consultations & publications on publications index page.

* Apparently people find the distinction between consultations &
  publications confusing so we're providing them all in a single place.
* I've had to introduce a `Publicationesque` superclass in which to
  include a couple of modules in order to make the whole thing work
  sensibly. I'm not overly enamoured of the name, but it'll do for now.
* I've introduced a `ConsultationPresenter` so that consultations can be
  displayed using the same template. It's possible that some of these
  methods would be better pushed into the model classes, but this'll do
  for starters.
* Note that although all the tests pass, a bunch of the `DocumentFilter`
  functionality doesn't take consultations into account e.g. the list of
  topics only includes ones in which publications appear. I plan to
  address these issues in later commits.
* Added tests for `ConsultationHelper#consultation_header_title` since
  we're now more reliant on it.
Make publications index work in JSON format with consultations.

* By adding `should_return_json_suitable_for_the_document_filter
:consultation` to the `PublicationsControllerTest`, this forces us to
make the JSON version of the action work for consultations. Before this
change if any consultations were returned, the JSON version of the
action failed. This in turn meant that infinite scroll was broken when
any consultations were returned.

* Unfortunately I've had to combine `PublicationPresenter` and
`ConsultationPresenter` into a single `PublicationesquePresenter` which
contains evil `case` statements. This is used by
`PublicationsController::PublicationesqueDecorator` to decorate all of
the returned models. I couldn't find a nicer way of doing this that
preserved the ActiveRecord::Relation behaviour of the returned
collection of models. It might be possible to improve on this by some
radical re-structuring of `DocumentFilterJsonPresenter` and subclasses,
but I'm not sure.

* I've removed `Whitehall::DocumentFilter#each_document_with_index`
since we can now simply use the decorated collection that
`PublicationsController::PublicationesqueDecorator#documents` returns.

* I've also change `PublicationFilterJsonPresenter#document_hash`
to use the presenter methods which was really where the main problem
was, because this code didn't work with consultations.

* I've also had to add a slightly unfortunate tweak to
`PublicDocumentRoutesHelper#model_name` when it is passed a presenter
instead of a model. This is necessary, because
`DocumentFilterJsonPresenter#document_hash` calls
`PublicDocumentRoutesHelper#public_document_path` and it would be
awkward to change this in just the `PublicationFilterJsonPresenter`
subclass. This way it's just as safe to pass a presenter decorating a
model as it is to pass the model itself.
Include topics with related consultations in publications filter.

* I've changed `Policy#published_related_publications` and the
corresponding cached count to include consultations as well as
publications.
* I thought about renaming `Policy#published_related_publications` and
  corresponding cached count method to
`#published_related_publicationesques`, but it didn't read very well and
I thought it might lead to more confusion.
* The migration updates the cached counts to include consultations.
* Unfortunately the `after_update` callback doesn't work if you put it
on the `Publicationesque` superclass. It might be worth considering
extracting the duplication somehow.
Avoid N+1 queries in publications index.

Now that we're loading consultations as well as publications, we need to
ensure that consultations' associations are not loaded one at a time.

It's not great that I've had to move the `has_one :response` association
into `Publicationesque`, but I can't think of a nicer way to do it.
Include organisations with consultations in publications filter.

* I've changed `Organisation#published_publications` to include
consultations as well as publications.
* I thought about renaming `Organisation#publications` to
`#published_publicationesques`, but it didn't read very well and
I thought it might lead to more confusion.
Test pagination works for consultations on publications index.
Improve test coverage for publications index page.

Specifically to cover more scenarios where consultations are included
alongside publications.
Test wasn't testing what it thought it was.

For some obscure reason the strange logic in
`DocumentFilter#find_by_slug` wasn't coping with being passed an
array of organisation instances. This meant that no filtering by
department was occurring and both publications were being returned.
However, there was no assertion to check how many documents were
returned.
Improve test coverage for publications index atom feed.

Specifically provide scenarios in which there are consultations as well
as publications.
Moved `#part_of_series?` method from presenter onto model.

A publication implements this method and so will override the `false`
default return value, while a consultation will always return false as
desired.
Migration should not depend on application code.

This migration was broken with the latest code, because e.g.
`ConsultationResponse` has become `Response`. This means it was no
longer possible to migrate from an empty database.