Stanford-Online/class2go — pull request #757 by jbau (2012-09-21 09:01:35+00:00)
Title: Jbau cs224n redir hotfix

Re-implemented the convenience redirector to use regexp instead of a pre-defined dictionary.

Also, look! Unit tests! You can run these by doing ./manage.py test convenience_redirect
yes, they all pass.

The dependency on the preview mode bit is calculated on the course home page. (this code was there already), so all the redirector has to do is to translate networking.class.stanford.edu to class.stanford.edu/networking/Fall2012 and the home page will decide whether to redirect to the preview page or not.

Yes, this is one more redirect, but it make implementation cleaner, since we don't have to look in the database in middleware and we already optimized by having the redirect go directly to /networking/Fall2012 instead of to /networking/ with another direct to follow. And also by having the home page redirect to the https preview page right away, rather than suffering another bounce from http -> https.

So, the redirect path will become http://networking.class.stanford.edu -> http://class.stanford.edu/networking/Fall2012 -> https://class.stanford.edu/networking/Fall2012/preview/ , adding one more redirect hop than currently.