alphagov/whitehall — pull request #1083 by tekin (2013-11-22 17:23:46+00:00)
Title: Fix attachment upload form

This fixes a bug that would prevent the upload fields on file attachments from being rendered when the STI `type` attribute was not set. Ideally, the `Attachment` class would be marked as abstract and the app would raise errors when an attempt is made to save one. Unfortunately we can't do this at present because mass-assignment is being used to manipulate attachments on `PolicyAdvisoryGroup`s and `CorporateInformationPage`s and the `type` attribute is protected from mass-assignment. Thus any new attachments added to these two models using the admin interface will be created as `Attachment` instances, not `FileAttachment`s.

I've attempted to tidy up the code as much as possible so as to avoid creating base `Attachment` instances, but until we change the way attachments on those two models are managed in admin, we cannot guarantee that they won't exist. I've also tidied up some legacy test code around the mass-assignment of attachments on editions.