Add missing testdata for the diff file attachment support.

These files were missing from my prior change.
Fix reversing URLs on Local Site with template caching turned on.

A while back on RBCommons, we hit a bug after enabling template caching
where URLs weren't reversing properly. Reversing would seem to work at
times, and at other times, the page would break due to a lookup failure.
In these cases, it was always failing to find a URL with local_site_name
in the kwargs.

This turns out to be due to a bug on our end, and not something due to
us overriding the url template tag.

When building the cached nodes and rendering the first time, all would
be well, but then we'd set url_node.kwargs to equal self.kwargs in our
custom template tag. Future renders would re-use the instances of our
tag, and therefore the kwargs and the url_node attributes. kwargs would
be populated with a 'local_site_name' key, and all would fail from there
on out.

We just need to copy our args/kwargs when setting url_node, and not
assign directly.
Merge branch 'release-1.7.x'
Allow setting a review request's status with just the can_change_status permission.

The review request API didn't allow changing a review request's status
by users other than the submitter when they had the 'can_change_status'
permission, unless they also had the 'can_edit_reviewrequest'
permission. 'can_edit_reviewrequest' should not have been required.

The API is now more careful about when it returns a 403, based on the
permissions and the data provided in the request.
Add support for permissions specific to Local Sites.

Local Sites had no equivalent of our custom permissions, like
can_change_status or can_submit_as_another_user. It also didn't grant
these abilities to administrators of Local Sites.

Now, a LocalSiteProfile defines a permissions dictionary, which contains
all granted permissions for the user. Local Site administrators
automatically have all permissions for a Local Site.

To do this, we make use of an AuthBackend's ability to do custom
permission lookups. The main function for this, has_perm, can take a
parameter for the object permissions are being looked up on.

This parameter is unused by defaut and in fact not allowed on any
built-in backends. Django doesn't make any real use of it. The intent
appears to be to pass an object like a ReviewRequest to it, but there's
no real rules governing this.

For our usage, passing a LocalSite as the object will have it look up
that permission in the user's list of permissions for the LocalSite. All
callers must then do when checking permissions is to pass the LocalSite
(or None) when calling has_perm.

The 'perms' context variable for templates has also been replaced with a
version that will pass the LocalSite for these requests.
Update for new exception syntax.

Python 2.6+ introduced a new syntax for catching exceptions with the exception
value. Instead of `except Exception, e`, it's now `except Exception as e`,
which is really much nicer. Since we're 2.6+ only now, we can convert to this.

Testing done: Ran unit tests.
Reviewed at https://reviews.reviewboard.org/r/4876/
Fix post-commit diff creation with unicode characters.

The post-commit diff fetch was returning a unicode object, but the guts of all
our diff stuff (Base64Field, hashlib.sha1) expected a str of bytes. This meant
that trying to use post-commit for any change that involved non-ascii
characters would fail with an exception on the backend (and an infinite spinner
on the front). We now explicitly encode the diff to utf-8 before creating the
review request, which fixes these issues.

Testing done:
Created some post-commit review requests for changes that previously failed.

Reviewed at https://reviews.reviewboard.org/r/4862/
Revert "Add support for permissions specific to Local Sites."

This reverts commit 63a9f97a9600800e8c41bfd961361c14643f1671.

Accidentally committed this instead of another branch. Still waiting for
review.
Fix showing private review requests in a couple lists.

The submitters page and the group review requests page weren't factoring
in the viewing user, preventing private review requests from showing up
for that user. The queries for these pages now pass in the viewing user.
Fix JavaScript unit test breakages from the recent Markdown changes.

The Markdown editor changes I recently made didn't pass the JavaScript
test suite. This brings the unit tests back to working order.
Factor in the "Blocks" list for the review request cache key.

When setting the Depends On field of a review request, the listed
review requests won't have their caches invalidated. Navigating to those
review requests won't show any entries for "Blocks" until you
shift-reload.

We now include the Blocks list as part of the ETag for caching the page.
Fix issues with last update bubbles and timestamp comparison.

We had some issues with timestamp comparisons that we never really
noticed, due to pages reloading on updates.

First of all, the Last Activity timestamp recorded in the template
matched the timestamp in the Last Update resource, due to how we
converted those two timestamps, but neither of those matched any
timestamp fields in any other API resources. This is because we
serialized the two former timestamps ourselves using isoformat(), but
the API uses DjangoJSONEncoder, which further normalized the timestamps.

Because of this, we couldn't compare timestamps from API calls to the
last activity timestamps. Now that Djblets's json_dumps uses
DjangoJSONEncoder for timestamps, we can use that instead of calling
the 'date' filter ourselves, and get some consistency across all
timestamps.

Now that that's done, we can mark the review request as updated when we
publish a reply, preventing an update bubble from appearing.
Provide better dirty state calculation for Markdown inlineEditors.

Getting the text contents of a CodeMirror widget every key press is
expensive, and resulted in some noticeable typing lag. Now that
inlineEditor allows callers to override dirty state calculation,
MarkdownEditor can provide its own implementation that just asks
CodeMirror if it's dirty. This removes the typing lag.
Clean up the diff loading style.

The diff loading style was a bit broken-looking. The "Revision" and
"New Change" headers jumped on load, and the spinner had no padding
around it.

It's impossible to properly align the revision headers without knowing
some of the visible line numbers and content and placing it in the
table, and any best-guesses are just guesses. The next best thing is to
just not show revision information until the file has loaded, which is
what we do now. It's a bit cleaner-looking, with just a filename and a
spinner (which now has some padding around it as well).
Fix fetching the list of blocks for a draft.

My recent change had a problem with drafts. It attempted to always
access 'blocks', but this isn't available on drafts. Now we only grab it
from the review request.
Merge branch 'release-1.7.x'
Remove resources.py and tests.py from webapi.

These accidentally came back to life after a merge. They're dead again.
Fix one more "except ..., e" spot.

Looks like I missed one in my earlier change. Trivial fix.
Show the blocks list on review UIs and the diff viewer.

The new 'blocks' variable wasn't provided on review UI pages or on the
diff viewer. Now, make_review_request_context will provide it if the
caller does not.
Add support for permissions specific to Local Sites.

Local Sites had no equivalent of our custom permissions, like
can_change_status or can_submit_as_another_user. It also didn't grant
these abilities to administrators of Local Sites.

Now, a LocalSiteProfile defines a permissions dictionary, which contains
all granted permissions for the user. Local Site administrators
automatically have all permissions for a Local Site.

To do this, we make use of an AuthBackend's ability to do custom
permission lookups. The main function for this, has_perm, can take a
parameter for the object permissions are being looked up on.

This parameter is unused by default and in fact not allowed on any
built-in backends. Django doesn't make any real use of it. The intent
appears to be to pass an object like a ReviewRequest to it, but there's
no real rules governing this.

For our usage, passing a LocalSite as the object will have it look up
that permission in the user's list of permissions for the LocalSite. All
callers must then do when checking permissions is to pass the LocalSite
(or None) when calling has_perm.

The 'perms' context variable for templates has also been replaced with a
version that will pass the LocalSite for these requests.