Fix various issues with configforms table views.

There were a few of bad assumptions made when using
TableView/TableItemView for configform item lists.

One was that there was already a <tbody> defined. This was the case in
the few places where we used it before, but isn't not always going to be
the case. We now add one if it's not already there.

The second bad assumption was that actions go on the element. In the
case of TableItemView, this is a <tr>. Now, ListItemView/TableItemView
subclasses can define a function to return where the actions should be
added. For TableItemView, this defaults to the last cell in the row.

The third bad assumption was that, by default, ListItemView would be
used if not specified otherwise, even for TableView. Now, ListView
subclasses can define their default.

Along with this, the template for TableItemView has been cleaned up to
remove extra whitespace, which matches a change made recently for
ListItemView.

Unit tests were added for all this. Some existing tests had to be
cleaned up, though, since they polluted prototype-level data.

Reviewed at https://reviews.reviewboard.org/r/6050/
Fix issues enabling extensions containing copy/pasted settings.

When enabling an extension and installing its media, we work with a lock
to ensure that two processes aren't attempting to install media at the
same time. We then remove the lock file. This happens until the old
stored version in settings matches up with the current version of the
extension.

Where this falls apart is if an administrator copy/pastes a settings
dictionary from one server (say, a test server) into a disabled
extension's settings in the database editor, and then tries to enable
it. The versions will match up, but the extension won't be installed
yet, so we'll go through the locking phase. However, since the versions
match, we don't actually create a lock, and then we blow up trying to
remove it.

If the extension's data is not yet installed, its old version (if any)
is not to be trusted. Treat it like a fresh install.

Reviewed at https://reviews.reviewboard.org/r/6054/
Clean up some PyFlakes warnings in Djblets.

This cleans up a few small PyFlakes warnings in the Djblets code. These
warnings were harmless.

Reviewed at https://reviews.reviewboard.org/r/6068/
Clean up all Djblets JavaScript warnings and errors from jshint.

This goes through and cleans up all the warnings and errors that jshint
reported. Only one of these (an extra comma) would lead to page
breakages, but the rest should help with some optimization and code
size.

There were two changes made that were bigger than just using '===' or
similar.

datagrid.js has had its initialization code moved to the bottom of
$.datagrid, in order to define functions up-front (as jshint wanted)
instead of defining functions after being called. In practice, this
wouldn't cause any issues, though.

scrollIntoView() now caches $(window), $(document), and $(this) in order
to reduce execution time. I had to condense var statements there anyway,
so I just moved those out.

Reviewed at https://reviews.reviewboard.org/r/6055/
Fixed log initialization on Windows.

The log initialization code for Windows was using the wrong module path for
'FileHandler'. This updates it to use the correct path, allowing the log
initialization to work again on Windows.

Reviewed at https://reviews.reviewboard.org/r/6056/
Add new template loaders for conditional caching and namespaced apps.

This adds two new template loaders intended to directly replace standard
Django template ones.

The new 'conditional_cached' template loader functions like Django's
'cached' loader, but does not cache if DEBUG is True. This helps a lot
with development, since it's no longer necessary to reload the server
after modifying a template.

The new 'namespaced_app_dirs' template loader is like Django's
'app_directories' loader, but accepts an optional namespace prefix in
the form of 'app.path:'. If specified, the list of template directories
will be limited to those owned by the given app path.

Reviewed at https://reviews.reviewboard.org/r/6070/
Move the Djblets release notes into ReST files.

This removes the old NEWS file and splits up all the release notes into
ReST files. These can later be shown directly on the Review Board
website, instead of having to go through the NEWS files on
downloads.reviewboard.org. This will also make it easier for us to link
to Djblets release notes in other docs.

Each of these files were copy/pasted from their NEWS sections, with some
macros and regexes used to transform them into the proper format. I also
went through some of them and fixed up styling, and added appropriate
ReST markup where needed.

Reviewed at https://reviews.reviewboard.org/r/6067/
Allow templates to override the list of actions in the Extensions page.

The Extensions page now includes a new 'extension_list_actions' block
that can be overridden to provide actions. By default, it includes the
"Scan for extensions" action. Templates extending this should retain the
parent block's content and then add to it.

Reviewed at https://reviews.reviewboard.org/r/6071/
Rename "Scan for new extensions" to "Scan for installed extensions".

This renames the scan action to say "installed" instead of "new," making
it more clear that we're not looking for new extensions from some remote
source, but rather those that have since been installed.

Reviewed at https://reviews.reviewboard.org/r/6072/
Fix display of form validation errors in config forms.

The config forms code wasn't allowing errors to be shown on the forms,
and had other issues that prevented proper error reporting:

1. We didn't implement a post() function on the view, meaning that
   TemplateView would default to a Method Not Allowed.

2. We weren't replacing the form instance within the page, resulting in
   a clean form being used, free of errors.

3. We weren't showing non-field errors on the form.

This fixes these cases so that form validation errors will be shown
correctly.

It also moves all the POST handling into the new post() function, where
it really belongs.

Reviewed at https://reviews.reviewboard.org/r/6076/
Fix some bad assumptions for web API auth backends.

The web API auth backend support made a couple bad assumptions that
made it hard to write additional backends.

If the Basic Auth backend was first, and it encountered something that
wasn't a Basic Auth authorization header, it would log failures, even
though it wasn't the target backend. We now perform the realm check
first before trying to parse it.

The base WebAPIAuthBackend class itself was assuming in some places that
backends would want a username and a password. Working around that
assumption meant overriding login_with_credentials(). Now, that function
no longer cares about the specific contents of credentials, and farms
out to the Django auth backends and to a new validate_credentials() for
any specifics, making it easier to override.

Along with this, we now log all credential information passed to the
API, being careful to mask any sensitive information.

Reviewed at https://reviews.reviewboard.org/r/6077/
Add an ability to hook into webapi method view calling.

WebAPIResource.__call__ no longer directly calls the method-based view
(get, create, etc.). Instead, it calls the new call_method_view()
function, which defaults to calling the view. Subclasses can override
this to perform additional checks or pass additional data without having
to decorate all views.

Reviewed at https://reviews.reviewboard.org/r/6086/
Fix infinite recursion when serializing object loops.

If two objects reference each other, and the relevant fields are listed in the
'expand' parameter, the serialization of the response would get a recursion
depth RuntimeError and return 500. This manifested in Review Board using the
"Depends On" field, with two review requests that referenced each other.

I've added some code to make each resource name in "expand" apply only once
for the entire serialization. This makes it possible to still expand deep into
object trees, but prevents infinite loops. To expand multiple levels with the
same resource name, it can be listed twice in 'expand'.

Testing done:
- Tested setting a review request's "Depends On" to itself.
- Tested a loop of two objects in "Depends On".
- Tested recursing multiple levels via:
  curl /api/review-requests/1/?expand=depends_on,depends_on | python -mjson.tool

Fixes bug 3442.

Reviewed at https://reviews.reviewboard.org/r/6095/