From 91ce214964e70e7ee5884e0ef6ffd0a9f4bc0c36 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 20 Dec 2012 14:59:21 -0500 Subject: [PATCH] Fix for Studio #96. --- cms/djangoapps/contentstore/utils.py | 26 ++++++++++++++++++++++---- cms/envs/test.py | 2 ++ cms/templates/settings.html | 8 ++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 6343098554..da2993e463 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -73,20 +73,38 @@ def get_course_for_item(location): def get_lms_link_for_item(location, preview=False): - location = Location(location) if settings.LMS_BASE is not None: lms_link = "//{preview}{lms_base}/courses/{course_id}/jump_to/{location}".format( preview='preview.' if preview else '', lms_base=settings.LMS_BASE, - # TODO: These will need to be changed to point to the particular instance of this problem in the particular course - course_id=modulestore().get_containing_courses(location)[0].id, - location=location, + course_id=get_course_id(location), + location=Location(location) ) else: lms_link = None return lms_link +def get_lms_link_for_about_page(location): + """ + Returns the url to the course about page from the location tuple. + """ + if settings.LMS_BASE is not None: + lms_link = "//{lms_base}/courses/{course_id}/about".format( + lms_base=settings.LMS_BASE, + course_id=get_course_id(location) + ) + else: + lms_link = None + + return lms_link + +def get_course_id(location): + """ + Returns the course_id from a given the location tuple. + """ + # TODO: These will need to be changed to point to the particular instance of this problem in the particular course + return modulestore().get_containing_courses(Location(location))[0].id class UnitState(object): draft = 'draft' diff --git a/cms/envs/test.py b/cms/envs/test.py index cb84f32ff1..a32f088582 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -77,6 +77,8 @@ DATABASES = { } } +LMS_BASE = "localhost:8000" + CACHES = { # This is the cache used for most things. Askbot will not work without a # functioning cache -- it relies on caching to load its settings in places. diff --git a/cms/templates/settings.html b/cms/templates/settings.html index 1266213906..1fa5b0acce 100644 --- a/cms/templates/settings.html +++ b/cms/templates/settings.html @@ -73,7 +73,7 @@ from contentstore import utils
- This is used in your course URL, and cannot be changed + This is used in your course URL, and cannot be changed
@@ -83,7 +83,7 @@ from contentstore import utils
- This is used in your course URL, and cannot be changed + This is used in your course URL, and cannot be changed
@@ -93,7 +93,7 @@ from contentstore import utils
- This is used in your course URL, and cannot be changed + This is used in your course URL, and cannot be changed
@@ -213,7 +213,7 @@ from contentstore import utils
- Introductions, prerequisites, FAQs that are used on your course summary page + Introductions, prerequisites, FAQs that are used on your course summary page