'redirect to course wiki url if the referrer is from a course page'

def _redirect_from_referrer(self, request, wiki_path):

    course_id = course_id_from_url(request.META.get('HTTP_REFERER'))
    if course_id:
        try:
            get_course_overview_with_access(request.user, 'load', course_id)
            return redirect('/courses/{course_id}/wiki/{path}'.format(course_id=course_id.to_deprecated_string(), path=wiki_path))
        except Http404:
            pass
