Fixes required module bug caused by 2+ main_call

When a required, uncompleted program module is found, the function
ProgramModuleObj.main_view_fn() is called. This function is a wrapper
for that module's main_call method.

Previously, the main_call was determined by self.main_view. When a
module (such as the TeacherEventsModule) has two main_calls,
self.main_view doesn't necessarily return the view you want. The
observed bug was that, when the Teacher Training and Interview Signups
ProgramModuleObj was made required, teachers would be redirected to the
Manage Teacher Training and Interviews view instead.

This commit replaces the reference to self.main_view with a reference to
self.get_main_view(tl), which was introduced in commit b11641b29d and
returns the correct main_call view, even in cases when there are
multiple main_calls.
Makes another get_main_view(tl) substitution

Substitutes module.main_view for module.get_main_view(tl) in
ProgramModuleObj.getCoreURL().

I'm not entirely sure that this change is necessary, since we shouldn't
ever have a CoreModule that has two distinct main_calls. However, it
shouldn't hurt to make this change. Unless we rely on the caching that
module.main_view provides.
Add LaTeX batch mode flags.

Add the following flags.
    -interaction nonstopmode
        This ensures LaTeX quits if a dependency (.sty) is missing.
    -halt-on-error
        This makes LaTeX quit on the first error instead of wasting
        time continuing to render a broken document. Note that this
        alone will stop the compiler on a syntax error but not on a
        missing .sty file.

To see what this commit does, go find studentschedule.tex, replace
"fullpage" with a nonexistent package name, and try to run
    python2 manage.py test modules
(really just the testSchedules programprintables test).
Before this commit, it should stop and wait for user input.
After this commit, it should just error out and move on.

On that note, maybe we should consider replacing os.system with
something like subprocess.check_call--to let us know immediately when
latex fails, rather than later on when we can't find the dvi file it
was supposed to produce.

Fixes #263.
Restore dvips landscape options for ps and svg.

This restores changes from 956521f3699de0bb5978bf36579523d513eef337
clobbered in the merge 7dcf5546fae6bae2bcb77bfa5cc96434eda0ffef
(mit-working into main).

The commit being restored was made in the main branch; its state prior
to the merge can be seen in 510b8d2fecba54e38259e4be6596f54d72823c62.
Partial restoration was previously done in
ea23ef2a46a8e26ca35d6488fd2c91c66a3e3b5a and
a32cb0cded41ecaecaf638370990ebb0bff3368b.

It is my guess that the clobbering was unintentional. So this commit
restores the flags passed to dvips to suppor rendering .ps and .svg
files in landscape mode. (It seems the ps and svg formats were
approximately never requested in landscape mode anyway.)
LaTeX: change os.system to subprocess.check_call.

subprocess.check_call throws an exception upon seeing a nonzero (i.e.
abnormal) exit value. For the price of a little verbosity, we get to
see when one of the commands fails *before* we attempt to run the next
command on its nonexistent output.

Occurrences of os.system in esp/esp/gen_media/inlinelatex.py are left
untouched since with those, we already check the exit value explicitly
and supply a custom message in case of error.
Make texescape safe to run on '\n'.

If x = '\n', then {{ x|texescape }} in its own paragraph causes
some problems because you get an isolated \\. LaTeX complains
at you that "There's no line here to end."

So cheat by putting a ~ (non-stretching, non-line-breaking space)
before every generated newline.

Side effect: generated newlines are no longer idempotent. I refrain
from making any claims about the correctness or desirability of this
side effect.
Fix completion certificates.

* Turn off HTML autoescaping. This is a LaTeX document!
* Replace \\ with ~\\ in case of empty class descriptions or such.
* Refer to parent_class for class descriptions and such.
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.
Added check availability module.
Changed from list to set for a bit higher efficiency.
Merge pull request #393 from pteromys/stable-jul12-bugfixes

Catalog preview and class documents
Integrated check availability module into availability module, deleted check availability module.
Fixes #239: mail server information moved to config file.
Changed concatenation to string formatting.
Added 'School' Field to onsite reg.

Added 'school' field to onsite student registration as per issue #495.
Field inputs data into 'school' field of studentinfo, but doesn't
fill in 'k12school' field or include the related autocomplete
capabilities. Field is optional.
Teacher events module management web interface.

Altered the existing teacher events module to be able to add and remove teacher training and interview timeslots. The name and friendly name are set automatically with a nice date format.
Fix #284 -- display SplashInfo statistics on dashboard

Since the lunch choices can be overridden by tags, this dynamically
generates entries on the dashboard according to which values have been
selected.
Added the option to morph into a volunteer
(cherry picked from commit db9c447bb6e67b1cb469be95d4f97109609e2828)
Fix typo in 057a2bc71c