Removed AHAH tab loading

This code is pretty complicated and will get more complicated once we
try to cache things.  Once we have better caching I don't think we
really need it anyway.
Groundwork for better video page caching

Added the CacheGroup class, which will handle storing cached data for
a video.  I also plan to use it to replace the UserCache class.

Added a bunch of documentation about how it works.

Added a utility class to create codes like our video ids and editor
nonces.  I figure we use this often enough that it's good to put in
utils.
Added cache to Video objects

This uses the CacheGroup code from the caching app.  Right we don't
actually store anything in the cache, but the code to invalidate it is
correct at least.

Allow subtitles versions to be unpublished even if they are not part
of a team video.  I think this should be allowed in theory and don't
like that it made the subtitles app dependent on the teams app.
However, the main reason for the change is to make testing things
simpler.

Bump enterprise version to pull in a fix from there
Use CacheGroup for the user cache

I think all everything is in place now and we can implement the actual
speedups now.
Speed up the add video to team section

It was actually fairly complex to calculate which teams you can move
the video to, so I moved it the form to a separate page.  The new page
doesn't look great but the old UI was to just dump you in the add
video form so I think it's not worse.

Store the result of the managed_teams() check in the user cache.

Moved the code to invalidate the user cache on team member changes to
the teams app.  I think it makes more sense to have it here.  Also
invalidate when the membership narrowings change.

Show the sharing buttons regardless if we are running from dev or not.
I'm not sure why we weren't but this makes things look more correct
while I'm testing the caching changes.

Added command to clear the cache
Cache more stuff in the videos page

Added a couple template tags to handle the simple cases.  Switched the
profile caching to use the new tags.

Cache the language list and avoid calling prefetch_languages() if we
have it cached.
Cache more stuff on the videos page

Tried to cache as much as possible in the video page cache.  On my
test page I'm down to 9 SQL queries which is many many less than
before.  There are a few things that seem tricky/impossible to remove
still:

  - Fetching the video/team video (Doubt we can get around this)
  - Permissions checks (maybe cacheable, but invalidation is tricky
    since we should invalidate if either the video or user changes)
  - Is the user a follower?  Same issue as the permissions checks
  - Sharing context (definitely cacheable, but I need to wrap my brain
    around the code)
  - Comments (definitely cacheable)
Fixed the unittests.

Made the user menu stuff its own template and made that template work
for both regular and anonymous users.  This removes the duplicate code
in header.html and base.html

Fixed warning when trying to cache things by the anonymous user.
Cache the sharing widget on the video page

Refactored share_utils a bit, that code was super ugly.

Simplified RTL calculation for videos.  There's no need to fetch the
subtitle version to look that up.
Cache the video page title

This shouldn't be needed once we implement #1463, but for now this
saves some DB queries on the page.
Add more functionality to CacheGroup

Added a bunch of code to integrate CacheGroup code with django model
class.  This should be able to replace the code in Video and
CustomUser to create a cache group for an instance.  In fact it should
be a nice improvement because with a cache pattern, we should be able
to fetch the instance and all cached values for that instance in using
a single get_many() call.

I think that this can achieve the dream of 0 DB queries for the video
page.  Using this code I think we should be able to handle the entire
page with the following 3 cache queries:

  - fetch the user and all its cached values from the cache
  - fetch the video and all it's cached values from the cache
  - (optionally) fetch the team and all its cached values from the
    cache.

Also added a convenience function to get a value from the cache and if
there's a cache miss compute it.
Switched classes to use ModelCacheManager

Added test function that can be used to test if a model's cache is
invalidated.
Migrated code to use the new cache group functionality

Removed the update view counter code from the video page (#1879).

Added way to get request.user from the user cache.

We now perform 0 DB queries once the video page is cached.

Changed video views to return 403 errors instead of 404 if there is a
permissions error.  This seems like the more correct code to return.
Added cache invalidation for teams

This somehow got lost in the shuffle.
Fixed exception on the language page
Add cache debug panel

Updated django-debug-toolbar.  This requires a dev build command.

For some reason I couldn't use the provided cache panel, so I
implemented a custom one.

Put the debug toolbar at the top of the middleware.  This way it can
report on the code from other middleware classes.
Speed up cache fetches

Removed the code to get the language choices from cache.  The code is
dirt simple so it's probably faster to calculate that fetch from
cache.  I made it so it's still cached in local memory though.

Refactored CustomUser.get_languages to return language codes instead
of UserLanguage objects.  That's how we're using it anyways.  Also
make it use the new caching code so that it can be pulled in with
get_many()

Use video.get_workflow() to avoid fetching the workflow twice.

Updated amara-enterprise revision to pull in a fix there.
More cache fixes

Fix call to request.use_cached_user() it was happening in the wrong
view decorator.

Cache comments and invalidate the video cache when a comment is saved.

Don't cache the video page headers.  This breaks when the user
switches tabs.  Instead cache the video url and comment counts.

Use video cache when calculating languages for the upload subtitles
form

Removed the SaveUserIP and ResponseTime middleware.  I don't think we
use this data at all, it's potentially slow, and it's messing with the
caching code.

Bumping version to pull in a fix from amara-enterprise
Fix showing reference language list (#1821)

The issue was a combination of 2 bugs (both should be fixed):

  - We would display the primary audio language as an option in the
    language list, even if it didn't have any versions.  In fact, it
    would be the default selection.
  - We would hide the language selector if the current language didn't
    have any versions.
Fixes for using cached users

Just use the DJANGO session key instead of our own one.  For all the
backends that we use, the value will be the user id.  Previously there
were issues surrounding the session value staying around after
login/logout.

Handle anonymous users, which stores None in the session.

Handle DB lookup errors.