Bullet-proof change descriptions with deleted file attachments.

Because of the ways that file attachments and change descriptions are stored,
it's possible to delete a file attachment from the database but still have its
old pk referenced from the change description. In this case, trying to render
that change description would crash because it no longer exists.

This change adds some bullet-proofing to ensure that we don't show a traceback.

Testing done:
Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6563/
Fix problems when adding invalid users to target_people via the API.

When doing a PUT on the ReviewRequestDraftResource, if find_user() returned
None, that would be added to the relation, generating a database error and
aborting the transaction. In production this worked OK but it didn't from the
API unit tests.

Now, after find_user() is called the return value is tested; if None then it
throws an ObjectDoesNotExist exception and skips getting added to the database.
In update() it checks for invalid_fields, which will contain target_people if
no user was found and returns a webAPI error of INVALID_FORM_DATA. So the HTTP
response gives an informative error, and None never gets added to the database.

Testing Done:
The unit test asserts that find_user() returns null, then checks that
find_user() is called, checks the response code for 105 (INVALID_FORM_DATA),
and that there is no TransactionManagmentError thrown by the database.

Reviewed at https://reviews.reviewboard.org/r/6559/
Merge branch 'release-2.0.x'
Fix a language-o I introduced.

Appending to a list in python uses "append", rather than "push". Ah, the life
of a polyglot.
Merge branch 'release-2.0.x'
Sandbox reviewboard.accounts.AuthBackend

Poorly-written AuthBackend implementations provided by extensions could
theoretically break parts of Review Board. While a number of the AuthBackend
calls are done from Django (and therefore can't be changed), there are several
Review Board-specific features that can be wrapped with sandboxing.

Now when an AuthBackend subclass from an extension throws an exception, Review
Board logs the errors with enough information to find which method in the
AuthBackend subclass threw the exception.

Testing Done:
Unit tests have been written to make sure that functions from an AuthBackend
subclass have been called, and when an exception is thrown it gets logged.

The tests fail without the sanboxing, and succeed with it.

Reviewed at https://reviews.reviewboard.org/r/6399/
Fix fetching commits by branch on GitHub.

When I fixed filtering of SVN commits by branch, several versions
ago, I broke filtering by branch on GitHub.

The New Review Request page was no longer passing the starting SHA,
which GitHub needed, resulting in all commits being returned. This call
has been fixed.

It's worth noting that the GitHub API allows for filtering by branch,
but you can't both use that and SHAs for pagination. The SHA is good
enough, if provided, so we'll continue to use that, falling back on a
branch if only a branch is provided. The code has been updated with
documentation to cover this.

Reviewed at https://reviews.reviewboard.org/r/6575/
Merge branch 'release-2.0.x'
Remove the defaults from the newer JSONFields.

The newer JSONFields added to WebAPIToken and WebHookTarget had a
default value, which MySQL is not okay with. This removes the defaults
and sets them to null by default, like every other JSONField we use.
Remove the initial value for WebHookTarget.extra_data in the evolution.

The original evolution adding the WebHookTarget.extra_data had an
initial value, and even with changing that in another field, it will
still apply on existing installs. This needs to be modified in order to
allow installation on MySQL.
Remove an old comment about Repository path:local_site constraints.

We had an old comment describing how a path:local_site unique constraint
was causing problems when archiving repositories. This was an issue
because an archived repository would keep the path, but wouldn't be
shown in the UI, resulting in a conflict when trying to add a new
repository with the same path.

We fixed this in 2.0 by including an archive timestamp in the key. The
comment hasn't been relevant for a while now, so we can safely delete
it.
Fix generating the path to the manual URL for dev builds.

The old manual URL generation function was assuming that any
non-released builds should us the 'dev' docs, but this is often wrong.
What we actually want is to use the 'dev' docs for any X.Y.0 releases
that aren't marked as "final". This changes the logic accordingly.

Reviewed at https://reviews.reviewboard.org/r/6579/
Sandbox reviewboard.attachments.mimetypes.MimetypeHandler

Extensions that create a MimetypeHandler subclass can throw exceptions inside
Review Board. The sections of Review Board that call those methods have been
sandboxed.

Now when a MimetypeHandler subclass from an extension throws an exception,
Review Board logs the errors. The error logs give enough information to find
which method in the MimetypeHandler subclass threw the exception.

Testing Done:
Unit tests have been written to make sure that functions from an
MimetypeHandler subclass have been called, and when an exception is thrown it
gets logged.

The tests fail without the sandboxing, and succeed with it.

Reviewed at https://reviews.reviewboard.org/r/6532/
Refactor the alphabetic paginator.

This updates Review Board for the associated Djblets change to refactor the
alphabetic paginator into a subclass.

Testing Done:
- Unit tests all pass
- All button cases manually tested. (Forward, back, first and last arrows, each
  letter).
- Verified that  changes to not affect any other module that inherits from
  datagrid (such as the groups list, or the all review requests list, the
  current 'master' of reviewboard with no changes to the userGrid).

Bugs closed: 829

Reviewed at https://reviews.reviewboard.org/r/6522/
Fix multi-select closing in the dashboard for Local Sites.

The multi-select closing in the dashboard wasn't providing any local
site information, and wasn't using the display ID for review requests.
We now pass the proper information to the template and JavaScript in
order to handle this case.

Reviewed at https://reviews.reviewboard.org/r/6588/
Fixes bug #3561
Merge branch 'release-2.0.x'
Clean up some unused crud from SCMTool classes.

SCMTools had a couple properties which were no longer used. This was confusing
when adding new ones. This change removes those.

Testing done:
Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6589/
Fix a merge-o.

Applying the alphanumeric datagrid patch caused a breakage. Trivial change.
Centralize serialization/deserialization of resource models.

Previously, all JavaScript resource models were responsible for
implementing toJSON() and parseResourceData() functions. In many cases,
there were inconsistencies in how they handled certain
serialization/deserialization operations.

Along with this, we had no way of mapping attribute names to JSON
fields. This meant that, in some cases, calling code had to know about
the JSON fields in order to perform certain operations (like
fine-grained saving of fields).

Now, resources list the attributes to serialize and deserialize, and can
provide a map between attribute names and JSON field names. They can
also list custom serializers/deserializers for different fields. All
common serializers are provided in a new RB.JSONSerializers object.

This doesn't fully remove the need for toJSON or parseResourceData
functions, but most are gone. Most others can be removed down the road
if we centralize text type processing into a mixin.

An upcoming change will allow fine-grained saving of fields based on
attribute names, allowing us to make faster API calls with less impact
on the server.

Reviewed at https://reviews.reviewboard.org/r/6587/
Merge branch 'release-2.0.x'