Fix Mako templates to always use updated request context

Fixed the edX middleware to lazily create request context for Mako templates, so that it is based on any changes made to the request object. 

Without this change, Mako templates for the courseware were rendered with the original user, rather than the user that had been updated by the courseware view. This had two side effects:
1. It defeated the ```prefetch_related``` call for the user's groups so ```has_access``` was not optimized
2. It defeated the preview's masquerade capability, so the Mako template always rendered the staff view, e.g. the "Instructor" tab was not hidden.

Added a Bok Choy test that verifies that the "Instructor" tab is correctly hidden when a staff member is viewing the course as a student.

Reviewers: @cpennington @dmitchell 
FYI: @ormsbee @adampalay @cahrens
Worth creating a helper function? The same code appears here and in shortcuts.py.