Allow updating file attachments.

Review Request #6387 — Created Sept. 30, 2014 and submitted — Latest diff uploaded

Information

Review Board
master
800
b775166...

Reviewers

This change adds a new model, FileAttachmentHistory, which aggregates multiple
FileAttachments together into a single unit. Within a history, each file
attachment has a revision. Any "legacy" attachments will be associated with a
new FileAttachmentHistory when the review request page is shown. The history
also contains a "display_position" field, which may eventually be extended to
allow users to re-order the list of attachments on the page.

This also adds an "Update" button to file attachments in the "Actions"
drop-down menu. When clicking this, users will be presented with an upload
dialog allowing them to upload a new file. When a public attachment is updated,
it adds a new revision. When a draft attachment is updated, it is replaced with
the new file.

While I was adding tests and validation to the UploadFileForm, I did some
refactoring. The review request is now passed in as part of the constructor,
which aids in validation. Additionally, I've made it just use self.files (part
of the django Form class) instead of needing to pass in the file a second time
to the create() method.

  • Loaded a review request with existing file attachments and saw that new
    FileAttachmentHistory entries were created for each one.
  • Updated existing file attachments and saw that the new ones were created,
    visually replaced the ones that they updated, and that publishing the draft
    created the correct change description.
  • Updated a file attachment multiple times without publishing the draft and saw
    that it replaced the new revision rather than creating multiple revisions.
  • Checked a file attachment that had not yet been published and saw that it
    did not have the "Update" action.
  • Ran unit tests.