-
-
reviewboard/attachments/models.py (Diff revision 1) The 2nd and 3rd lines should be lined up at the same column as the first parameter: ...Key(FileDiff, ... verbose_name=... related_name=...
-
reviewboard/diffviewer/diffutils.py (Diff revision 1) There should never be more than one. I think we should handle that case as an error and assert.
-
reviewboard/reviews/models.py (Diff revision 1) I think it would make more sense to say "associated with a FileDiff"
-
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 1) This is probably not right. In the case where old diffs have binary file entries, we'd want to fall back on the old behavior.
Inline File Attachments
Review Request #3457 — Created Oct. 25, 2012 and discarded
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
Description | From | Last Updated |
---|---|---|
What is this? |
david | |
Wrap to < 80 chars. |
chipx86 | |
The 2nd and 3rd lines should be lined up at the same column as the first parameter: ...Key(FileDiff, ... verbose_name=... … |
david | |
So normally, you probably want: try: binary_file_attachment = get_object_or_none(FileAttachment, filediff=filediff) except MultipleObjectsReturned: # log something here binary_file_attachment = None Actually, … |
chipx86 | |
I think it would make more sense to say "associated with a FileDiff" |
david | |
Blank line between these. |
chipx86 | |
Same comment here. |
david | |
Blank line between these. |
chipx86 | |
template tags should start at indentation level 0, and instead the command should be indented inside the {% ... %}. … |
chipx86 | |
Template variables should not have spaces around the variable name. {{file.binary_file_attachment.file}} |
chipx86 | |
I don't think we want this. Let's fall back to what we had before. There's too many legitimate review requests … |
chipx86 | |
This is probably not right. In the case where old diffs have binary file entries, we'd want to fall back … |
david | |
Should be inserted alphabetically in the import list. |
chipx86 | |
This should be in the next import group, since it's part of the project, and not in the 3rd party … |
chipx86 | |
Two blank lines. |
chipx86 | |
The "Error:" isn't needed. We're in an exception, so that's a pretty good assumption. |
chipx86 | |
This needs to convey some useful information we can use to track what went wrong. If we see this in … |
chipx86 | |
Blank line. |
chipx86 | |
Space before { |
chipx86 | |
Not totally thrilled with redefining all the action logic. We should standardize it (pull the common parts out of the … |
chipx86 | |
No spaces inside {{}} (Yes, the old code had them, but it's really old code and should be changed.) |
chipx86 | |
We use 1 space indentation in HTML. Make sure all the new HTML is only indented 1. |
chipx86 | |
This can probably just be merged into the parent . |
chipx86 | |
I would expect this (and the equivalent on the right-hand side) to be on its own . Also, can you … |
chipx86 | |
I'm concerned about accessing thumbnail twice. This will currently cause a lot of logic to happen twice. Perhaps the thumbnail … |
chipx86 | |
Should this be interfile_binary_file_attachment.thumbnail? |
chipx86 | |
The {% trans %} lines should go on their own lines for readability. |
chipx86 | |
Here too. |
chipx86 | |
Yeah I don't think this approach is correct. The prior code is more what I'd expect, but if it's causing … |
chipx86 | |
Since you're just returning this immediately, you can do: try: return get_object_or_none(...) except MultipleObjectsReturned: logging.error(...) return None |
david | |
I think it might be better to write this as "if not file[filedifftype]" That would check for cases where file[filedifftype] … |
AA aam1r | |
Same as above (i.e. might be better doing "if not" rather than "is None") |
AA aam1r | |
Same as above (i.e. might be better doing "if not" rather than "is None") |
AA aam1r | |
Extra docs are always nice, but for unit tests, it really should be a one-liner. You can have the rest … |
chipx86 | |
Needs to be a sentence (needs a period at the end) |
SL slchen | |
I think you should wrap these in try/except statements to catch any exceptions that might be raised |
AA aam1r | |
We're using "fileattachment, "diff_fileattachment," "file_attachments," and "diff_file_attachment." It's a bit inconsistent. I'd prefer if we kept an underscore between "file" … |
chipx86 | |
Should be alphabetical. |
chipx86 | |
Should use underscores to separate words in variables when appropriate. This should be "file_diff_type". |
chipx86 | |
This is a little awkwardly written. Can you change it to: "file_diff_type can be either 'filediff' or 'interfilediff'." |
chipx86 | |
Did you mean this, or: &.left, &.binary-left Also, space before "{". |
chipx86 | |
Same comments here. |
chipx86 | |
And here. |
chipx86 | |
And here. |
chipx86 | |
Mixins are neat and all, but my preference is to avoid them in cases like this. The code should be: … |
chipx86 | |
Similarly, this shouldn't be a mixin, as it brings in a lot of code. Instead, the elements using the various … |
chipx86 | |
Now that this is multi-line, can you put the on its own line? |
chipx86 | |
You'd have to test this, but I don't know that we need this here. Unless we're operating on elements right … |
chipx86 | |
No need for colspan="1" |
chipx86 | |
Same. |
chipx86 | |
And here. |
chipx86 | |
And here. |
chipx86 | |
Indentation: remove 1 leading empty space from line 7 |
SL slchen | |
I think mimeparse is a 3rd party lib, it should go right after: from django.test import TestCase |
SL slchen | |
Nitpick: alphabetical |
SL slchen | |
I think you can change the indentation to: diff_file_attachment = FileAttachment.objects.create( caption='binary', file=file, mimetype='image/png', filediff=filediff) |
SL slchen | |
So, something I realized is that this is going to introduce new performance degradation, since we'll be doing 1 SQL … |
chipx86 |
-
-
-
reviewboard/diffviewer/diffutils.py (Diff revision 1) So normally, you probably want: try: binary_file_attachment = get_object_or_none(FileAttachment, filediff=filediff) except MultipleObjectsReturned: # log something here binary_file_attachment = None Actually, though, this code should not be in this file. The diff viewer should remain ignorant of the other apps (attachments and reviews). It's also going to increase the cache size quite a bit by caching the file attachment along with the metadata. The templates, though, are customizable, and so it can access such things. I'd suggest we do something there. Right now, we're just showing a path, and that can be reached by providing some template tag that does the query, given the filediff's ID, but we should really decide what's being shown later. Whatever that is will end up doing the above query instead, and rendering something (a review UI, probably) using it.
-
-
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 1) template tags should start at indentation level 0, and instead the command should be indented inside the {% ... %}. Same with the others in this file.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 1) Template variables should not have spaces around the variable name. {{file.binary_file_attachment.file}}
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 1) I don't think we want this. Let's fall back to what we had before. There's too many legitimate review requests that exist, and we don't want to show errors there. We also will probably have to set a size cap for uploading file attachments, and don't want to mislead users.
Change Summary:
+ Modified comments and format based on review - Reverted changes to diffutils for returning binary file attachment along with the file, instead: + Added the query for FileAttachment as a template tag in difftags - Reverted changes to diff_file_fragment that could affect existing review requests Please see updated Descriptions and Testing Done sections for detailed information.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+79 -3) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Screenshots: |
|
-
This is looking pretty good. I'm not sure I understand your change description--can you rewrite it to be a concise summary of what you've done and what you have left to do?
-
Change Summary:
Updated change description + Added a summary + Highlighted what has been done, is in_progress, and is next
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Branch: |
|
Change Summary:
Changes: Add inline preview UI for binary files in diffviewer. Add action buttons (links) for downloading/commenting/reviewing the binary file when appropriate. Show thumbnail when available. Show previous version of the binary file side-by-side when interfilediff is available. Add an additional parameter to get_binary_file_attachment_for tag to enabling fetching for fileattachment associated with interfilediff. * Affected files: + reviewboard/diffviewer/templatetags/difftags.py + reviewboard/static/rb/css/diffviewer.less + reviewboard/templates/diffviewer/diff_file_fragment.html Problem: Sidebyside views using <td colspan="2"> are not aligning properly in Chrome (shown in the screenshots attached. There is a second attempting to use lists instead of table commented out in the template. With that approaching, I can make the thumbnails list like the actions links but can't make them span the whole width appropriately. I have tried width=50% for <li> but that's hard coded so won't very well if it's a newfile and importantly still doesn't align like the text diffs. (Please see screenshot) To Test: There's no way to upload a binary file attachment yet so to test this UI one must 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.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Branch: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+252 -5) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Screenshots: |
|
Change Summary:
Added unit test for inline file attachment.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 4 (+329 -6) |
-
So nothing stands out as being super wrong with the HTML (though I have changes I'd like to see made). Still, it's looking very wrong on Chrome. I wasn't sure which screenshot corresponded with which code. I'm guessing the "li width=50% not aligned" was the commented out code, which isn't what we want. The first block is more correct. Can you make the changes here, make sure the screenshots represent that new state of the world, and then if there are still problems, we'll go over them in person?
-
reviewboard/attachments/tests.py (Diff revision 4) Should be inserted alphabetically in the import list.
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 4) This should be in the next import group, since it's part of the project, and not in the 3rd party group.
-
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 4) The "Error:" isn't needed. We're in an exception, so that's a pretty good assumption.
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 4) This needs to convey some useful information we can use to track what went wrong. If we see this in logs, we won't have anything to go on.
-
-
-
reviewboard/static/rb/css/diffviewer.less (Diff revision 4) Not totally thrilled with redefining all the action logic. We should standardize it (pull the common parts out of the review request and make them generally available), and then if we want it to be a different color or something, that's easy to override here.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) No spaces inside {{}} (Yes, the old code had them, but it's really old code and should be changed.)
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) We use 1 space indentation in HTML. Make sure all the new HTML is only indented 1.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) This can probably just be merged into the parent <td>.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) I would expect this (and the equivalent on the right-hand side) to be on its own <tr>. Also, can you perhaps rewrite this to use elif? Like: {% if not interfile_binary_file_attachment %} "This is a binary file ..." {% elif interfile_binary_file_attachment.thumbnail %} {{...thumbnail}} {% else %} "No preview..." {% endif %}
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) I'm concerned about accessing thumbnail twice. This will currently cause a lot of logic to happen twice. Perhaps the thumbnail function should be modified to cache the last value.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) Should this be interfile_binary_file_attachment.thumbnail?
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) The {% trans %} lines should go on their own lines for readability.
-
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 4) Yeah I don't think this approach is correct. The prior code is more what I'd expect, but if it's causing issues on Chrome, we'll need to investigate further.
Change Summary:
+ Improved code according to Christian's comments + Added more details error and debug messages for get_binary_file_attachment_for tag. + Extracted .actions and .actions-container to defs.less. And extended them in diffviewer.less to overwrite them with inline-file-attachment-action specific settings. + Aligned the file attachment icon in the header in diff_file_fragment.html; Put actions and thumbnail previews on two different rows; and updated control logic in it. + Cleaned up description. ! Please review the logic below (are these the behavior we want?): ~ an icon will be displayed for binary file in the header ~ if a binary file cannot be retrieved via a filediff then there won't be a 'Download' or 'Review' action, but there will be a 'Add Comment' action for it ~ if there is no review_ui for the binary file type there won't be a 'Review' action for it, just 'Download' and 'Add Comment' ~ if there is a review_ui for a file attachment retrieved via filediff there will be both 'Download' and 'Review' actions for it ~ if a older version of the binary file cannot be retrieved via a 'interfilediff' then there won't be a 'Download' action for it, vice versa TODOs: > make the actions-container exist even when the list of action is empty, to make it look consistent > center the text messages (please see fileattachment=none screenshot) > chrome column misaligned problem has been identified and currently being worked on
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 5 (+389 -112) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Screenshots: |
|
-
It would be nice if you could remove old screenshots and just attach the ones corresponding to the current state of the feature. I don't see much to change here but Christian should probably take another look at the HTML.
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 5) Since you're just returning this immediately, you can do: try: return get_object_or_none(...) except MultipleObjectsReturned: logging.error(...) return None
Change Summary:
+ Make inline file attachment UI's sidebyside cell aligned in Chrome by using two colgroups for inline file attachment UI instead of the 4 colgroups used by text diffs. + Fix css to avoid disappearing right border issue in Chrome. + Refactor get_binary_file_attachment_for tag according to David's suggestion. + Screenshots of how the UI looks like now in different scenarios ! Please review the logic below (are these the behavior we want?): ~ an icon will be displayed for binary file in the header ~ if a binary file cannot be retrieved via a filediff then there won't be a 'Download' or 'Review' action, but there will be a 'Add Comment' action for it (Should there be a Add Comment feature? If so, should it be similar to the ones implemented for file attachment already?) ~ if there is no review_ui for the binary file type there won't be a 'Review' action for it, just 'Download' and 'Add Comment' ~ if there is a review_ui for a file attachment retrieved via filediff there will be both 'Download' and 'Review' actions for it ~ if a older version of the binary file cannot be retrieved via a 'interfilediff' then there won't be a 'Download' action for it, vice versa
Testing Done: |
|
||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 6 (+400 -113) |
||||||||||||||||||||||||||||||
Added Files: |
-
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 6) I think it might be better to write this as "if not file[filedifftype]" That would check for cases where file[filedifftype] could be: False, None, 0, (), [], {} or "". Right now, you are only checking for "None"
-
reviewboard/reviews/models.py (Diff revision 6) Same as above (i.e. might be better doing "if not" rather than "is None")
-
reviewboard/reviews/models.py (Diff revision 6) Same as above (i.e. might be better doing "if not" rather than "is None")
Change Summary:
Add commenting functions to inline file attachments with no review UI and address comments. + Hook up the necessary javascript to allow commenting on inline file attachments that does not have a review UI. + Cache thumbnail in mimetype_handler. + Refactor one checks to be using 'if not'. + s/binary_file_attachment/diff_file_attachment. + Fix css mixin definitions to work with the new version of less. Add two more previews 1. newfilediff-nofileattachment.png when there's no file attachment associated with the binary file diff 2. comments.png add comments when there's no Review UI for the mimetype
Summary: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+413 -120) |
||||
Removed Files: |
|||||
Added Files: |
|||||
Screenshots: |
|
-
This looks good to me. Because of the scope of the change, I'd like to have Christian take one last look at it before we push it. Nice work!
-
There's a series of mostly small things left, but the overall work looks good. Looking forward to this! Poke me as soon as you have a change up and I'll do another review.
-
reviewboard/attachments/tests.py (Diff revision 7) Extra docs are always nice, but for unit tests, it really should be a one-liner. You can have the rest in comments.
-
reviewboard/attachments/tests.py (Diff revision 7) We're using "fileattachment, "diff_fileattachment," "file_attachments," and "diff_file_attachment." It's a bit inconsistent. I'd prefer if we kept an underscore between "file" and "attachment" in all instances.
-
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 7) Should use underscores to separate words in variables when appropriate. This should be "file_diff_type".
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 7) This is a little awkwardly written. Can you change it to: "file_diff_type can be either 'filediff' or 'interfilediff'."
-
reviewboard/static/rb/css/diffviewer.less (Diff revision 7) Did you mean this, or: &.left, &.binary-left Also, space before "{".
-
-
-
-
reviewboard/static/rb/css/diffviewer.less (Diff revision 7) Mixins are neat and all, but my preference is to avoid them in cases like this. The code should be: .inline-actions-left, .inline-actions-right { // All the common stuff here. } And then have the .inline-actions-left and .inline-actions-right rules define their own specific stuff (like their own floats and 'a' rules). The reason is that, while it's neat to be able to include data like this in lesscss, in the end it's really just turning into even more CSS code the browser has to load in and keep separate, and it's more work to debug. It's equivalent to copy/paste.
-
reviewboard/static/rb/css/diffviewer.less (Diff revision 7) Similarly, this shouldn't be a mixin, as it brings in a lot of code. Instead, the elements using the various "inline-actions-*" classes should be also specifying "actions" as a class. More reuse, less debugging and less output.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 7) Now that this <th> is multi-line, can you put the <a> on its own line?
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 7) You'd have to test this, but I don't know that we need this here. Unless we're operating on elements right away, we don't have to worry about the DOM being ready.
-
reviewboard/templates/diffviewer/diff_file_fragment.html (Diff revision 7) Just to make sure, is this what you're expecting the logic to be: if (file.moved and file.num_changes == 0) or (file.newfile and not interfile_diff_file_attachment) ? Just want to be sure about the operator precedence.
-
-
-
-
-
-
reviewboard/attachments/tests.py (Diff revision 7) I think you should wrap these in try/except statements to catch any exceptions that might be raised
Change Summary:
+ Improve naming conventions: s/fileattachment/file_attachment; s/filedifftype/filediff_type + Improve comment readability - Remove mixins and update css rules to promote css rules reuse - Remove unnecessary colspan="1" declarations + Fix Bug by calling RB.setFileAttachmentComments after the diff_file_attachment null check + Preview image (newfilecorrupted.png) for scenarios where the new (revision) file can not be retrieved (eg. new file is corrupted or not uploaded correctly)
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 8 (+410 -120) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added Files: |
-
-
-
reviewboard/attachments/tests.py (Diff revision 8) I think mimeparse is a 3rd party lib, it should go right after: from django.test import TestCase
-
reviewboard/attachments/tests.py (Diff revision 8) I think you can change the indentation to: diff_file_attachment = FileAttachment.objects.create( caption='binary', file=file, mimetype='image/png', filediff=filediff)
-
Looks quite good, but there's one thing I realized. Going into detail below.
-
reviewboard/diffviewer/templatetags/difftags.py (Diff revision 8) So, something I realized is that this is going to introduce new performance degradation, since we'll be doing 1 SQL query per binary file, which can add up. This is something I've been working to reduce, and the good news is, we should be able to do it without a ton of trouble. The method we're using these days is to do computations of all the objects we need in review_detail or, in this case, diff, in reviews/views.py. We'd get the list of filediffs, the list of attachments, and precompute their associations in one go. The template can then access the proper attachment without even needing a template tag, simplifying the whole thing. The plan of attack would be: 1) Change your code for get_file_attachments to take a flag indicating whether binary file attachments should be included (include_diff_attachments bool). Default it to False. 2) Change the get_file_attachments call in the diff function to pass True to include_diff_attachments. 3) Iterate through the results and split the values into two: The file_attachments we currently pass, and a map of filediff IDs -> attachments. This would look like: file_attachments = [] diff_file_attachments = {} for file_attachment in review_request.get_file_attachments(True): filediff_id = getattr(file_attachment, 'filediff_id', getattr(file_attachment, 'interfilediff_id', None)) if filediff_id: diff_file_attachments[filediff_id] = file_attachment else: file_attachments.append(file_attachment) for file_attachment in review_request.get_inactive_file_attachments(True): # Same as above, except only for the diff_file_attachments map. (Something like that.) 4) Pass 'diff_file_attachments' to the context in render_to_response. 5) In the template, instead of the template tag, do: {{diff_file_attachments|getitem:filediff.pk}} Same with interfilediff.pk This should produce the same effect, but with fewer queries (just one new one for the inactive file attachments, in fact!), and no need for a new template tag. This may seem complicated, so please come to me with any questions.
-
-
reviewboard/attachments/tests.py (Diff revisions 7 - 8) Needs to be a sentence (needs a period at the end)
-
Change Summary:
+ Improve diff_file_fragment.html and diff_file_attachment test Renamed variables in template so make it more clear: s/diff_file_attachment/dest_diff_file_attachment s/inter_file_attachment/source_diff_file_attachment Fixed url bug caused by an empty context['review_request'] reference. Fix style problems in test and evolution. + New preview screenshot for when displaying multiple binary files across different revisions TODOs: * address stale data issue * after stale data issue rerun test and condense essential test cases into easily commitable form