alphagov/whitehall — pull request #911 by tekin (2013-10-02 16:19:33+00:00)
Title: Fix topics#show and other refactorings.

The main thrust of this commit is to fix the topics#show page so that it correctly lists statistical publications as apposed to statistical data sets, mirroring organisations#show. As part of the work, I thought I'd tidy up some stuff that's been bothering me for a while. In particular, the use of associations in place of scopes.

Associations are being used in a few places where scopes are more appropriate. They are both simpler and more re-usable - by adding scopes to the Edition model, they can be used by anything that has an :editions association. This reduces the duplication between models.

Also, the state machine gives us scopes for edition states for free, so we don't need to define associations for stuff like published_polices. Associations should only ever be used if you intend to manipulate the association by adding/removing from it.

I've also killed off some unused class methods on Classification.

Note that the ordering by classification_memberships.ordering on the policies association was a red herring - this column is not being used and editions that are associated with topics are generally ordered explicitly using the in_reverse_chronological_order scope. The column should probably be dropped.