diff --git a/lms/djangoapps/course_wiki/views.py b/lms/djangoapps/course_wiki/views.py index ff6e08abf5..47112fc1d3 100644 --- a/lms/djangoapps/course_wiki/views.py +++ b/lms/djangoapps/course_wiki/views.py @@ -30,6 +30,19 @@ def course_wiki_redirect(request, course_id): course = get_course_by_id(course_id) course_slug = course.wiki_slug + + + # cdodge: fix for cases where self.location.course can be interpreted as an number rather than + # a string. We're seeing in Studio created courses that people often will enter in a stright number + # for 'course' (e.g. 201). This Wiki library expects a string to "do the right thing". We haven't noticed this before + # because - to now - 'course' has always had non-numeric characters in them + try: + float(course_slug) + # if the float() doesn't throw an exception, that means it's a number + course_slug = course_slug + "_" + except: + pass + valid_slug = True if not course_slug: