Disable commenting when there's a pending draft of a review request.

A common mistake is to put up a new diff or file attachment and then try
to comment on it before publishing the draft. This doesn't work, and
will fail on an API level, but we didn't tell the user at any point that
they should expect problems doing that.

Now, the dialog will tell the user they must publish before they can
comment on the diff or file. All the fields will be disabled.

Note that bug #831 requests that we *allow* commenting. That's a much
bigger problem to solve, and one we won't be solving as part of this
change. This just fixes the unexpected failure case.
Improve file attachment comment links.

The file attachment comments in reviews had a link which looks similar to diff
comments. The text of this link is the filename, and the destination was the
download URL.

In the case where the attachment has a review UI, we want the link target to be
the review UI instead of the download URL. This change adds that in (with the
ability for the review UI to customize the link, for example, to link to a
specific page). This also includes some code for the review UI to customize the
text of the link, for example, to list which page the comment is on.

Testing done: Tested this in conjunction with our premium pdf review UI.

Reviewed at http://reviews.reviewboard.org/r/4148/
Improve file attachment comments in review emails.

Comments for file attachments in review emails were kind of crummy. They'd show
either the caption or the filename (unlike the web UI, which showed both). They
linked to the download URL, even when there was a review UI. And finally, they
wouldn't show comment thumbnails.

Testing done:
Set up a review and a reply and checked out the preview-email URLs.

Reviewed at http://reviews.reviewboard.org/r/4149/
Update the docs database.
Refactor our per-file diff rendering code into a DiffRenderer class.

DiffRenderer is responsible for taking the output of get_diff_files, and
some configuration (highlighting, collapse state, etc.) and rendering
diff output. It separates out the various responsibilities of the old
function, such as computing the cache key and rendering to strings and
HttpResponses.

There's one DiffRenderer per thing to render. It's created, used, and
thrown away.

A DiffRenderer is accessed by get_diff_renderer or
get_diff_renderer_class, rather than relying on using DiffRenderer
directly, allowing for some extensibility.

The new tests rely on kgb for function spies.
Fix review request field state for drafts.

The reviewRequest object being constructed for review request pages
wasn't using the draft details, which meant that on new review requests,
the reviewers would appear blank. That would prevent a publish from
working.

Now, the appropriate fields are loaded from {{review_request_details}},
which will have the correct information.
Port the unauthenticated/existing draft Comment Dialog changes to master.

This updates the Comment Dialog to slim down when unauthenticated or
when there's an existing draft, just like the recent change for 1.7.

With this change, CommentEditor now requires a ReviewRequest. Unit tests
had to be updated to account for this.

Unit tests were also added for all the new states.
Merge branch 'release-1.7.x'
Don't set drafts to be loaded initially.

This was preventing discarding from working properly. The draft appeared
loaded, but had no ID, so it was never fetched and therefore never
destroyed.
Fix unit tests with gCommentIssueManager.

gCommentIssueManager was being referenced when creating the comment
dialog, but in a way that wouldn't allow undefined if it didn't exist.
This impacted unit tests. Now, a commentIssueManager can either be set
in options, or window.gCommentIssueManager will be referenced.
Switch to using the cached template loader.

The cached template loader will cache the path to a template, given a
template name. Unlike the standard loaders, which will search every
location every time, this will only search the location once per thread.

This is not a memcached-based solution, but rather local memory, so
every thread will start with a fresh cache.

In my tests, this sped up the dashboard and review request pages by
~100-120ms, after the first load.
Add a getPrototypeOf compatibility function.

Older browsers don't have getPrototypeOf, so add a compatibility
function for it. This is mostly for IE's benefit.
Move opcodes_with_metadata into a DiffOpcodeGenerator class.

This new class performs all the same functions as the original
functions. Some of the code has been moved out into helper functions
for organization issues, but the logic hasn't changed.

This is part of an effort to clean up the diff viewer code and make it
more extensible.
Create a base Differ class and move some centralized stuff into it.

The two differs now inherit from Differ. This centralizes the
"interesting line" registration, and even the interesting line header
registration.

The filetype header maps have been moved into filetypes.py.

A tiny optimization was made, which was to check the diff compat version
1 (Myers differ) first, and not second. It won't make a huge difference,
but it's silly we didn't do that before.
Move chunk generation out of diffutils and into DiffChunkGenerator.

This class handles all the responsibilities of diff chunk generation.
It's basically the same code as before, but some things were able to be
cleaned up. For example, all the nested functions are gone, and instead
are just methods of the class. Functions can access self.<whatever>
instead of variables that happen to be in scope or variables. The yields
don't have to pass chunk_index and then increment it themselves.

This drastically shortens what's in diffutils.py. It also reduces how
much populate_diff_chunks now has to do.
Increase the size of the review request actions.

The review request actions were hard to hit on smaller screens. In
general, given how important they are, they're just too small. This
increases the size and makes the more prominent and easier to hit.
Fix the upload dialogs on the review UI pages.

The upload dialogs didn't contain the Django forms needed to populate
the on-screen forms, due to not using make_review_request_context. This
function (which hopefully we can kill in the future) has been moved into
reviewboard.reviews.context (to prevent a circular dependency) and is
now used in the review UI rendering code.
Fix action event handling on the review UI page.

The review UI page didn't have the new #review_request div around it,
which prevented action registration from working. It's now added.

On top of this, the success handler has been removed for file attachment
uploading, since the new objects will just respond to events instead and
do the right thing.
Merge branch 'release-1.7.x'
Prevent the page from jumping when modifying an issue state.

The introduction of the issue summary table had an annoying problem
where the page would scroll slightly after clicking Fixed, Drop, or
Reopen. The reason is that the matching entry in the table would be
added/removed, and that would affect the scroll offset.

We now work around that by updating the scroll offset after modifying
the table to scroll by the appropriate difference. Users won't see it
jump anymore.