If mitxmako.middleware has ever been imported, then render_to_string
works correctly (which is why we didn't see this in the rest of
edx-platform). However, if it hasn't (like in a celery worker), then
using mitxmako.middleware errors out.
[LMS-1085]
Themes do not necessarily want all of the available LMS routes, such
as `/jobs` and `/university_profiles`. This change splits up the
`lms/urls.py` file and selectively enables/disables routes based on
whether or not a theme is enabled. This is a naive solution for now;
a better solution gives themes a way to selectively overrides such
routes.
Additionally, with the `MKTG_URL_LINK_MAP` setting that hits certain
routes immediately on each page render (whenever the `marketing_link`
helper function is called), themes may crash if they don't leave
all marketing link routes present in `lms/urls.py`. This change also
provides the ability to override the `MKTG_URL_LINK_MAP` in the
settings.
Finally, modify the mitxmako marketing URL middleware to not try to
reverse disabled URLs, which are those keys in the map whose values
are `None`.
To avoid confusion about where these files come from, add a header
comment upon preprocessing that warns people to not modify the
generated files directly, and points them to the appropriate
template file.
When loading a Mako template from a Django template, the file
encoding of the Mako template was left unspecified. In some cases,
this would cause the Mako template to be interpreted as an ASCII
template, resulting in blowups if the template was encoded in
UTF-8 (e.g., lms/templates/footer.html).
Now, both the input and output encodings are specified as UTF-8.
Rather than directly invoke command-line Python (and Mako) from the
assets Rakefile, or call an external Python script, use a Django
management command to preprocess all asset template files.
An "asset template file" is defined as a static asset file with a
file extension indicating that it needs to be run through a template
engine prior to Sass/CoffeeScript compilation or packaging with other
assets. The preprocess_assets management command will look through
all of the files listed in the `STATICFILES_DIRS`, preprocessing each
as needed. Preprocessing strips off the special template file
extension, creating a new file in the process.
Currently, the only variable accessible in an asset template file is
the `THEME_NAME`, defined in the settings.