Moved some logic out of the views.

That logic now lives in the service objects.