Make class documents show up in catalog preview.

This way, teachers who try to add class documents don't get confused
when said class documents don't show up in the preview.

ClassSubject.objects.catalog is kind of magical and selects a bunch of
related data in one giant query. Our catalog-rendering code assumes
the presence of said data, so wherever we invoke it we should pass it
classes fetched via ClassSubject.objects.catalog.

We could use catalog_cached instead of catalog since correctness of
student counts (if they even appear) isn't important in the catalog
preview. However, the performance hit is tiny since few people even
look at catalog previews--and whatever comes out of render_class_core
*needs* to be correct because that will be cached and reused in the
actual catalog.

(Said observation about caching also implies that student confusion is
a relevant motivation for this fix.)
Make render_class_core depend on qsdmedia.Media.

This is in case teachers upload class documents and then immediately
check the catalog preview to see whether they show up.

Some remarks to the future:

1. This will likely require adjustment when the schema simplification
   project gets merged.

2. Using depend_on_row instead of depend_on_model implies we won't
   catch when a document moves from one class to another. However, I'd
   bet that almost never happens; and I think it's worth not having to
   regenerate the whole catalog every time a teacher uploads a file.

3. This silently fails to empty the right cache if it hits a DataTree
   node with more than one ClassSubject on it. I suspect such DataTree
   errors have enough other symptoms that we can pretend they never
   happen. Also, in a few months, remark 1 will make this irrelevant.
Merge pull request #393 from pteromys/stable-jul12-bugfixes

Catalog preview and class documents
Merge branch 'main' into issue406
Merge branch 'main' into issue406
Merge branch 'main' into issue406
Added editing availability to admin check availability module.
Not have to scroll to the bottom of the page each time you edit a resource/classroom.
Put forms on research page at the top of the list instead of bottom.
Fixes bug in create_membership_method

If the user_types Tag is used to define a new user type, that user type
is passed as a unicode string to create_membership_method, and is used
to set the name of a dynamically created method that checks for
membership in this user class. The __name__ attribute of this method
must be a regular string, but it was being cast to a unicode string if
user_class was a unicode string from the user_types Tag.

This fix casts user_class back to a regular string to prevent this
problem.
Minor tweak of ajax_sections GET handling
Fixes bug in onsite schedule_students

Fixes bug in ProgramModuleObj.deadline_met() caused by the upgrade to
Django 1.4.

During the upgrade to Django 1.4, specifically in
93d46cfb29f03cc821f301cffa77ec205dbf19a2
we changed our auth middleware. Now, request.user is a SimpleLazyObject
that evaluates to an ESPUser, rather than an ESPUser.

Normally, the SimpleLazyObject resolves requests to its attributes by
passing those requests on to the inner ESPUser object. However, when
the __dict__ attribute of request.user refers to the __dict__ attribute
of the SimpleLazyObject itself, rather than that of the inner ESPUser
object. Thus, checking to see if some key exists in the ESPUser's
__dict__ fails, because the check is actually being performed on the
SimpleLazyObject's __dict__. This was causing onsite schedule_students
to not show links for adding and removing classes, since these links
only appear if deadline_met() is True, which only happens if
'onsite_local' is in the ESPUser's __dict__ and has a value of True.

Fixes this by calling isOnsite() (which correctly resolves to the inner
ESPUser) rather than checking for 'onsite_local' manually. isOnsite()
already performs this check, so we should be good.
Making fraction_full() actually a fraction.
As mailman script is currently unhelpful, disabling for now.
Merge pull request #604 from learning-unlimited/shulinyeMinorFixes

Various minor fixes to small things
Merge branch 'stable-jul12-bugfixes' into main

This is to catch the two commits from pull request #393 which haven't
yet made it into any other branch.

Apologies for dredging up ancient history.
Merge branch 'main' of github.com:learning-unlimited/ESP-Website into main
Make list of classes on teacherreg page update properly

We had a caching bug because the cached inclusion tag
{% render_teacher_list_row %} was accepting 2 additional arguments besides
the class, which made it impossible for cache dependencies (e.g.
depend_on_row, depend_on_cache) to flush the cache for specific classes.
The solution here is to remove the extra arguments.  I was able to restore
the functionality of the friendly_times_with_date argument within the
template tag, but the 'can_edit' isn't going to work (that's a user
dependent variable which is incompatible with this type of caching
anyway).
Prevent integer overflow on program creation form

In case anyone lazily decides to type a very large number on the form,
this avoids an unexplained server error.
Fix code formatting in lottery controller