From 0bf79eb587c8314cc978cfb355680f0990a37262 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 19 Dec 2012 20:54:43 -0500 Subject: [PATCH] append some character, in this case a '_', if the course number is really a full-on number. The Wiki library interprets this incorrectly - to date we've always used non-numerical values. --- lms/djangoapps/course_wiki/views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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: