Couple of fixes for editor notes

Fixed exceptions when note.user is None.

For TeamEditorNotes, input team/video in the constructor.  This allows
for the possibility of displaying notes for a different team than the
team that owns the TeamVideo.
Remove highlighted_qs from teams list

We aren't using it anymore.
Better way to query counts for teams list

Use subselects instead of annotate (which uses group by) to count
members.  This runs much faster.

Use a similar query to count videos, which avoids an extra query for
each team on the list.

Renamed member_count() to members_count().  I think it's nicer for the
name to have the same form as videos_count().
Avoid extra queries to check team membership for the teams index

Before we using an extra query for each team on the page.  Changed it
so we query team membership when we fetch the teams.
Speedup User dashboard queries

The old queries were very slow in a puzzling case: where they matched
0 Action objects.  I'm not really sure why that is, but using extra()
makes for more straightforward SQL and the queries perform better.
Use select_related() on the user dashboard page

This reduces the number of queries substantially.  The difference was
about 3-4 queries per Action item when I was testing.
More speedup for the team activity pages

Split the activity into 2 categories:
  - "videos" most activity on team videos
  - "team" members joining/leaving and team video deletion

Having to only select 1 or the other makes the queries much faster.
Also speed up the team videos query substantially with an extra()
call.
Merge pull request #1798 from pculture/speedup-team-activity2

More speedup for the team activity pages
Merge pull request #1799 from pculture/speedup-user-dashboard

Speedup user dashboard
Merge pull request #1800 from pculture/speedup-teams-list

Speedup teams list
Fixed bad attribute name
Merge pull request #1801 from pculture/notes-refactor

Couple of fixes for editor notes
Hopefully fix a deadlock that I've been seeing fairly often

The deadlock happens like this:
  - We get a request to add a version at the same time as a request to
    regain the lock on the subtitles

  - In the request to add the version, we SELECT the language and get
    a read lock on it.
  - In the request to regain the lock, we UPDATE the language and get
    a wrote lock on it (but are now waiting on the read lock to
    finish)
  - In the request to add the version, we UPDATE the language (because
    we are changing subtitles_complete).  This is now waiting on the
    other request's write lock -- and we now have a deadlock.

I think that's the order of events at least.  I was able to simulate
something like that and did in fact get a deadlock error.

The solution is to use SELECT FOR UPDATE to get a write lock before
doing any work.  This makes the regain-lock request wait to get its
writelock and prevents the deadlock.
Merge pull request #1802 from pculture/locking-fix

Hopefully fix a deadlock that I've been seeing fairly often
updates refs to master
One more attempt at avoiding activity spikes

It seems like the last change may have helped, but we still are
getting some activity spikes.  This change is one more attempt to try
to fix them.
I think this one should really fix the activity issues

Limit activity on the user profile page to actions in the last 30
days.  This prevents the crazy queries that totally kill server
performance.
Speedup the TeamMember admin page
Merge pull request #1803 from pculture/speedup-team-member-admin

Speedup the TeamMember admin page
Remove useless query from the homepage

Not really that important, but this page does get hit alot and the
query was not used at all.

Also removed template code that was outside a block tag, so wasn't
getting used either.