From 522b76e8477843eda3ad42777d2062b42d329c00 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 23 May 2013 16:27:05 -0400 Subject: [PATCH 1/4] PREVIEW_LMS_BASE must now be set (default value does not work for both edge and edx). https://edx.lighthouseapp.com/projects/102637/tickets/331 --- cms/djangoapps/contentstore/utils.py | 2 +- cms/djangoapps/contentstore/views/component.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index ea3e3ecd6a..35451cf7cc 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -88,7 +88,7 @@ def get_lms_link_for_item(location, preview=False, course_id=None): if settings.LMS_BASE is not None: if preview: - lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', 'preview.' + settings.LMS_BASE) + lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE') else: lms_base = settings.LMS_BASE diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 89b5e8bdc7..30005d4524 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -179,8 +179,7 @@ def edit_unit(request, location): break index = index + 1 - preview_lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', - 'preview.' + settings.LMS_BASE) + preview_lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE') preview_lms_link = '//{preview_lms_base}/courses/{org}/{course}/{course_name}/courseware/{section}/{subsection}/{index}'.format( preview_lms_base=preview_lms_base, From a03a4fdd07ce9e53cac029e9d3cf8732a5ea4224 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 23 May 2013 16:45:10 -0400 Subject: [PATCH 2/4] PREVIEW_LMS_BASE must now be set (default value does not work for both edge and edx). Make this work locally as well. https://edx.lighthouseapp.com/projects/102637/tickets/331 --- cms/envs/aws.py | 1 + cms/envs/common.py | 1 + cms/envs/dev.py | 1 + cms/envs/test.py | 1 + 4 files changed, 4 insertions(+) diff --git a/cms/envs/aws.py b/cms/envs/aws.py index 9fabb3b9e8..12d661a21c 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -81,6 +81,7 @@ with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file: ENV_TOKENS = json.load(env_file) LMS_BASE = ENV_TOKENS.get('LMS_BASE') +MITX_FEATURES['PREVIEW_LMS_BASE'] = ENV_TOKENS.get('PREVIEW_LMS_BASE') SITE_NAME = ENV_TOKENS['SITE_NAME'] diff --git a/cms/envs/common.py b/cms/envs/common.py index d6752686d7..58f39efa7e 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -41,6 +41,7 @@ MITX_FEATURES = { # Enable URL that shows information about the status of variuous services 'ENABLE_SERVICE_STATUS': False, + 'PREVIEW_LMS_BASE' : None } ENABLE_JASMINE = False diff --git a/cms/envs/dev.py b/cms/envs/dev.py index 203e4bd909..638612294b 100644 --- a/cms/envs/dev.py +++ b/cms/envs/dev.py @@ -55,6 +55,7 @@ DATABASES = { } LMS_BASE = "localhost:8000" +MITX_FEATURES['PREVIEW_LMS_BASE'] = "localhost:8000" REPOS = { 'edx4edx': { diff --git a/cms/envs/test.py b/cms/envs/test.py index 6d78b0d7d6..cdee14e16d 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -82,6 +82,7 @@ DATABASES = { } LMS_BASE = "localhost:8000" +MITX_FEATURES['PREVIEW_LMS_BASE'] = "localhost:8000" CACHES = { # This is the cache used for most things. Askbot will not work without a From 138ad3988fd4b06c238076f262ba14dfdb7cb3e7 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 23 May 2013 17:06:02 -0400 Subject: [PATCH 3/4] Update test (and set PREVIEW_LMS_BASE to something different so we can actually test the method). --- cms/djangoapps/contentstore/tests/test_utils.py | 2 +- cms/envs/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py index 3b755b0ec2..0757992f2f 100644 --- a/cms/djangoapps/contentstore/tests/test_utils.py +++ b/cms/djangoapps/contentstore/tests/test_utils.py @@ -26,7 +26,7 @@ class LMSLinksTestCase(TestCase): link = utils.get_lms_link_for_item(location, True) self.assertEquals( link, - "//preview.localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us" + "//preview/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us" ) diff --git a/cms/envs/test.py b/cms/envs/test.py index cdee14e16d..8a3f9ba158 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -82,7 +82,7 @@ DATABASES = { } LMS_BASE = "localhost:8000" -MITX_FEATURES['PREVIEW_LMS_BASE'] = "localhost:8000" +MITX_FEATURES['PREVIEW_LMS_BASE'] = "preview" CACHES = { # This is the cache used for most things. Askbot will not work without a From e0bb4ad4dd60b12230fa9bc27ea3e5fe91b9a417 Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 28 May 2013 12:04:48 -0400 Subject: [PATCH 4/4] Preview url is read in from environment file. --- cms/envs/aws.py | 2 +- cms/envs/common.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cms/envs/aws.py b/cms/envs/aws.py index 12d661a21c..f6064229e6 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -81,7 +81,7 @@ with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file: ENV_TOKENS = json.load(env_file) LMS_BASE = ENV_TOKENS.get('LMS_BASE') -MITX_FEATURES['PREVIEW_LMS_BASE'] = ENV_TOKENS.get('PREVIEW_LMS_BASE') +# Note that MITX_FEATURES['PREVIEW_LMS_BASE'] gets read in from the environment file. SITE_NAME = ENV_TOKENS['SITE_NAME'] diff --git a/cms/envs/common.py b/cms/envs/common.py index 58f39efa7e..7e2fc12ba1 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -39,9 +39,8 @@ MITX_FEATURES = { 'STUDIO_NPS_SURVEY': True, 'SEGMENT_IO': True, - # Enable URL that shows information about the status of variuous services - 'ENABLE_SERVICE_STATUS': False, - 'PREVIEW_LMS_BASE' : None + # Enable URL that shows information about the status of various services + 'ENABLE_SERVICE_STATUS': False } ENABLE_JASMINE = False