Add ability to use email in Gitlab authentication

Older versions of Gitlab API v3 only allow authentication using email instead
of "login" parameter that Review board currently uses.

See https://github.com/gitlabhq/gitlabhq/commit/559e83d30004e0c41a30f4ce3463f695eb7e26a1

Testing Done:
Unit tests pass. Tested authentication with email againts different versions of
Gitlab.

Reviewed at https://reviews.reviewboard.org/r/5591/
Merge branch 'release-1.7.x' into release-2.0.x
The cache setting has been moved into a dictionary variable in django 1.3.

This change updates settings_local.py.tmpl to use CACHES instead of
CACHE_BACKEND.

Reviewed at https://reviews.reviewboard.org/r/5651/
Merge branch 'release-1.7.x' into release-2.0.x
Fix a typo.

s/parames/params/. Trivial fix.
Merge branch 'release-1.7.x' into release-2.0.x
Add AuthBackend.search_users() hook function

As discussed in review 5503, this adds an overrideable function that can be
used to replace the default user-search filter.

Testing Done:
All tests pass aside from a few VCS-dependent ones, which are skipped.

Reviewed at https://reviews.reviewboard.org/r/5635/
Fix unit tests to cope with extensions static media changes.

The changes to the location for extensions static media caused a huge number of
unit tests to break, due to the updates required checks. This change creates
both the current and legacy media directories as part of the test
initialization, and updates one test that checks the number of failing
updates checks to handle the fact that there are now two media directories that
get checked.

Testing done: Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/5658/
Make use of gravatars configurable.

When external internet access is blocked, using Review Board is annoying
because it tries to load gravatars, which can spin for a long time on every
page load, and show broken images. This change adds a setting for whether
gravatars should be used.

Testing done:
Looked at the page header, user infobox, and user page sidebar, and saw that
they all no longer contained broken images.

Fixes bug 3030.

Reviewed at https://reviews.reviewboard.org/r/5656/
Properly handle text attachment encodings for thumbnail generation.

Uploading a utf-16le encoded text file as an attachment would cause a
traceback, since it can't be coerced to unicode using the default encoding.
Since we have the mimetype, we can pull the encoding out of that, and decode
properly.

Testing done: Ran unit tests and tested uploading file through the web UI.

Fixes bug 3282.

Reviewed at https://reviews.reviewboard.org/r/5630/
Merge branch 'release-1.7.x' into release-2.0.x
SCM Web Hooks for reviewboard : Phase 1

Generate url infrastructure for hosting services so that they can be called to
access web hooks. Added repo_urlpatterns to the service base class. Modified
registration and unregistration of hosting services to add and remove
urlpatterns respectively.

Testing Done:
Wrote test case HostingServiceUrlPatternTests in hostingsvcs.tests.py. I've
tested the addition and deletion of url patterns during registration and
unregistration, respectively. Added tests for cases when the url_patterns are
not defined. Also tested adding bitbucket url patterns (see screenshot). All
tests have passed. :)

Reviewed at https://reviews.reviewboard.org/r/5510/
Add GitHub post-receive hook to close review requests automatically.

This is a GitHub post-receive hook that will automatically close review
requests as "submitted" after a push. To determine which review requests should
be closed, it scans through each commit's commit message for the following
strings (case-insensitive): "Reviewed at <reviewboard_url>/r/<id>" or "Review
request #<id>". The regex used for this can be overriden in settings_local.py.

Testing Done:
Added the post-receive webhook URL to a private GitHub repository, and tested
different pushes:
- Commit with a review request ID that is not submitted (verified that the
  review request is closed and set to submitted)
- Commit with a review request ID that is already submitted (got a warning that
  the review request is already submitted)
- Commit without a review request ID in the commit message (got a debug message
  that no matching review request ID was found)
- Commit with a private review request (verified that the review request is closed)
- Commits referencing the same review request ID
- Multiple commits
- Merge commits
- Branch creation and deletion
- Commits pushed to two branches

I also overrode the regex and flags in settings_local.py, and got the expected
change in matching review request IDs.

Reviewed at https://reviews.reviewboard.org/r/5596/
Add confirmation when discarding a review request.

This prompts the user for confirmation when discarding a review request through
Close -> Discarded, which will help prevent accidental discards.

Testing Done:
On a review request, I clicked Close -> Discarded, and got the confirmation
dialog. Clicking "Cancel" left the review request unchanged, and clicking "OK"
discarded the review request.

Bugs closed: 3117

Reviewed at https://reviews.reviewboard.org/r/5659/
Fix up a few webapi-lint errors.

The webapi-lint script had one unicode issue that was causing it to crash.
After I fixed that, I went through and fixed a handful of small issues that it
found.

Testing done:
* Ran webapi-lint
* Ran unit tests

Reviewed at https://reviews.reviewboard.org/r/5662/
Add management commands for enabling, disabling, and listing extensions.

When things go wrong with extensions, it's difficult to solve without
going into the database. This change aims to help with that by offering
management commands for enabling and disabling extensions, and for
listing all available (or all enabled) extensions.

'enable-extension' and 'disable-extension' take an extension ID, and
will enable or disable.

'list-extensions' will by default list all registered extensions.
Passing --enabled will limit this to enabled extensions.
Streamline rb-site install.

Many of the options rb-site install presented were advanced options that
a new admin likely didn't need to deal with. For example, the static and
media URLs, web server, Python loader, and the option for file-based
caching.

In order to simplify the first-time install experience, these wizard
pages have been hidden behind an --advanced flag, leaving only the
options that most users will need to deal with.

We also don't want to support mod_python anymore, so this has been
removed entirely.

In total, this takes us from 13 wizard pages to 8.
Allow continuing when hitting a DB sync error in rb-site.

A problem people sometimes hit is forgetting to create the Review Board
database or setting the right permissions before they proceed with
rb-site install. This can lead to a failure when synchronizing the
database, and then the need to delete the site directory and start over.

We now present a helpful error with the ability to continue and try
again as many times as needed.

Fixdes bug #2126
Switch to the HTML5 DTD.

We were using the XHTML 1 Transitional DTD for the longest time for
Review Board. This ends up putting the browsers into a mode where
some of the more recent rules won't apply. For the most part, we're
unaffected by any of these quirks, but I ran into something I was
working on where this did matter. It's also more likely to impact us in
the future.
Attempt to make directories writable on rb-site upgrade.

When upgrading an existing site, there should be at least one directory
("uploaded") that is writable by the web server. We can use this as a
reference point for all other directories that need to be made writable.

We now stat that directory and change ownership of all the other
directories.

I've also added uploaded/files as a generated directory. Technically,
this can be created on-the-fly, but since we know we want it, and make
the other directories, we may as well make this one up-front.