Inline File Attachments

Review Request #3457 — Created Oct. 25, 2012 and discarded — Latest diff uploaded

Information

Review Board
master

Reviewers

Add inline file attachment support.

FileAttachment now has a foreign key that associates it with a FileDiff. FileAttachment associated 
with a FileDiff is filtered from the get_file_attachments call so binary files that are suppose to 
be displayed inline will not appear in the review request file attachment box as well. DiffViewer 
template diff_file_fragment.html uses the get_binary_file_attachment_for assignment tag to fetch
the inline file attachments by querying for FileAttachments associated with the filediff or 
interfilediff. Binary files uploaded with a diff will now be displayed inline, with thumbnail,
download link and a link to MIME type specific review UI if available. If a review UI is not 
available for the MIME type of the binary file, a 'Add Comment' option will be available to the 
users with the same interface and workflow as the existing file attachments commenting system.
* There's no way to upload a binary file attachment yet so to test this UI, I have manually associate an uploaded fileattachment with a filediff in 
  the database by making a filediff for that file and supplying the filediff_id to the fileattachment.

Passing Manual tests:
> Made sure filediff_id column is added to FileAttachment, and can be used to query for a FileAttachment when given a filediff
> Made sure the basic file information is displayed inline (file name, file-icon, download link)
> Made sure "This is a binary file. The content cannot be displayed." when the query for FileAttachment returns None
> Made sure when more than one FileAttachment are associated with one FileDiff, an error is logged and None is returned
> Made sure get_binary_file_attachment will query and return the correct filediff or interfilediff when available
> Made sure when a review_ui exist for the file type of the binary file a link is available to the review_ui
> Made sure if the fileattachment for the binary file is found, a link to download the file is shown
> Made sure if a thumbnail is available for the fileattachment, it is displayed
> Made sure that if a FileAttachment is associated with a FileDiff, it will not be included in file-list in the review_request_box template
> Made sure if the new binary file attachment can't be retrieve but the older revision of it can then the older revision is displayed on the right regardless
> Made sure that the two horizontal table cells in sidebyside view have the same width
> Made sure a "Add comment" option exist if review UI does not
> Made sure "Add comment" function like existing file attachments container action

Passing Unit test(s):
> ./reviewboard/manage.py test -- reviewboard.attachments.tests:BinaryFileAttachmentTests


!Failing Manual tests:
> Made sure there is no stale data: comments/reviews add to the file attachment will be reflected immediately