I'm re-submitting this branch for review, because Martin suggested in his UI review to use simplified view where the user must confirm that a bug attachment is indeed a patch, if Launchpad believes it is not. When a user sets the "patch" flag to an value considered to be inconsistent by Launchpad, a click to the "change bugattachment" and "create new bug comment" buttons leads him to a new view "+confirm-is-patch", where he must explicitly set his choice of the "patch" flag again. As a drive-by, I also fixed bug 182286 ("Content Type:" on bug attachment page is editable even when it has no effect). I simply removed the code that unconditionally sets teh content type of patches to "text/plain". As noted by Kjell Braden in a comment on bug 182286, this is sometimes simply wrong. The alternative would have been to carry over the overriding of the content type setting for patches to the new view class BugAttachmentPatchConfirmationView. That would have been a bit more effort for a questionaable feature than to fix bug 182286 which simply meant that I had to remove a few lines of code and tests. The implementation is quite straightforward: - a new template and a new view class for the page "+confirm-is-patch" - a mixin class BugAttachmentContentCheck with some methods to check if the content type as guessed by Launchpad matches the patch flag selection made by the user. This mixin class is used in BugAttachmentEditView and in BugMessageAddFormView. test: ./bin/test -vv -f lp.bugs stories.bugattachments Demo/QA: - Create a new bug attachment with a filename like "123.diff" but do not check the "patch" flag - Ensure that you are led to the "+confirm-is-patch" view. - Ensure that the "patch" flag is currently set for this attachment: On the main bug page, it should appear in the "patches" portlet. - choose "no" in the confirmation view and click "change" - The attachment should now appear in the "attachments" portlet of the main bug page. - Create a new bug attachment with a filename like "456.png" and check the "patch" flag. - Ensure that you are led to the "+confirm-is-patch" view. - Ensure that the "patch" flag is currently _not_ set for this attachment: On the main bug page, it should appear in the "attachments" portlet. - choose "yes" in the confirmation view and click "change" - The attachment should now appear in the "patches" portlet of the main bug page. - Change the "patch" flag of the two new attachments in their "edit" view. If the new value looks wrong to LP, you are again led to the "+confirm-is-patch" view. screenshots: http://people.canonical.com/~adeuring/confirm-patch-1.png Add diff file without setting the "patch" flag http://people.canonical.com/~adeuring/confirm-patch-2.png confirmation view for the new attachment http://people.canonical.com/~adeuring/confirm-patch-3.png Add a PNG file and check the "patch" flag http://people.canonical.com/~adeuring/confirm-patch-4.png confirmation view for the new attachment/patch http://people.canonical.com/~adeuring/confirm-patch-5.png confirmation view shown when the "patch" flag is set to a value which Launchpad considers to be wrong. = Launchpad lint = Checking for conflicts. and issues in doctests and templates. Running jslint, xmllint, pyflakes, and pylint. Using normal rules. Linting changed files: lib/testtools@ lib/lp/bugs/browser/bugattachment.py lib/lp/bugs/browser/bugmessage.py lib/lp/bugs/browser/configure.zcml lib/lp/bugs/interfaces/bugattachment.py lib/lp/bugs/stories/bugattachments/10-add-bug-attachment.txt lib/lp/bugs/stories/bugattachments/20-edit-bug-attachment.txt lib/lp/bugs/templates/bug-attachment-confirm-is-patch.pt lib/lp/bugs/templates/bug-attachment-edit.pt == Pylint notices == lib/lp/bugs/interfaces/bugattachment.py 20: [F0401] Unable to import 'lazr.enum' (No module named enum) 28: [F0401] Unable to import 'lazr.restful.fields' (No module named restful) 29: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)