Take advantage of class-based generic views.

Also moved more logic inside the form.