Refactored course_nav middleware to isolate the django-wiki hack,
remove unnecessary code, and clarify what it's doing.