From d549194ba3ec6a86c72ddaedb1cd6b63d8a9e007 Mon Sep 17 00:00:00 2001
From: Jeremy Bowman <jbowman@edx.org>
Date: Tue, 31 Oct 2017 15:50:14 -0400
Subject: [PATCH] PLAT-1775 Move help tokens configuration from startup to
 settings

---
 cms/envs/common.py | 4 ++++
 cms/startup.py     | 5 -----
 lms/envs/common.py | 4 ++++
 lms/startup.py     | 5 -----
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/cms/envs/common.py b/cms/envs/common.py
index a0d36d2f8f3..ad59310c022 100644
--- a/cms/envs/common.py
+++ b/cms/envs/common.py
@@ -133,6 +133,7 @@ from openedx.core.djangoapps.theming.helpers_dirs import (
 )
 from openedx.core.lib.license import LicenseMixin
 from openedx.core.lib.derived import derived, derived_dict_entry
+from openedx.core.release import doc_version
 
 ############################ FEATURE CONFIGURATION #############################
 
@@ -1382,6 +1383,9 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
 ############## Settings for Studio Context Sensitive Help ##############
 
 HELP_TOKENS_INI_FILE = REPO_ROOT / "cms" / "envs" / "help_tokens.ini"
+HELP_TOKENS_LANGUAGE_CODE = lambda settings: settings.LANGUAGE_CODE
+HELP_TOKENS_VERSION = lambda settings: doc_version()
+derived('HELP_TOKENS_LANGUAGE_CODE', 'HELP_TOKENS_VERSION')
 
 # This is required for the migrations in oauth_dispatch.models
 # otherwise it fails saying this attribute is not present in Settings
diff --git a/cms/startup.py b/cms/startup.py
index 4ed7cf44900..f49a2aed658 100644
--- a/cms/startup.py
+++ b/cms/startup.py
@@ -15,7 +15,6 @@ from openedx.core.lib.django_startup import autostartup
 settings.INSTALLED_APPS  # pylint: disable=pointless-statement
 
 from openedx.core.lib.xblock_utils import xblock_local_resource_url
-from openedx.core.release import doc_version
 from startup_configurations.validate_config import validate_cms_config
 
 
@@ -41,10 +40,6 @@ def run():
     xmodule.x_module.descriptor_global_handler_url = cms.lib.xblock.runtime.handler_url
     xmodule.x_module.descriptor_global_local_resource_url = xblock_local_resource_url
 
-    # Set the version of docs that help-tokens will go to.
-    settings.HELP_TOKENS_LANGUAGE_CODE = settings.LANGUAGE_CODE
-    settings.HELP_TOKENS_VERSION = doc_version()
-
     # validate configurations on startup
     validate_cms_config(settings)
 
diff --git a/lms/envs/common.py b/lms/envs/common.py
index 61787e10777..74aecb184c4 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -44,6 +44,7 @@ from openedx.core.djangoapps.theming.helpers_dirs import (
     get_theme_base_dirs_from_settings
 )
 from openedx.core.lib.derived import derived, derived_dict_entry
+from openedx.core.release import doc_version
 from xmodule.modulestore.modulestore_settings import update_module_store_settings
 from xmodule.modulestore.edit_info import EditInfoMixin
 from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
@@ -3295,10 +3296,13 @@ REDIRECT_CACHE_KEY_PREFIX = 'redirects'
 ############## Settings for LMS Context Sensitive Help ##############
 
 HELP_TOKENS_INI_FILE = REPO_ROOT / "lms" / "envs" / "help_tokens.ini"
+HELP_TOKENS_LANGUAGE_CODE = lambda settings: settings.LANGUAGE_CODE
+HELP_TOKENS_VERSION = lambda settings: doc_version()
 HELP_TOKENS_BOOKS = {
     'learner': 'http://edx.readthedocs.io/projects/open-edx-learner-guide',
     'course_author': 'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course',
 }
+derived('HELP_TOKENS_LANGUAGE_CODE', 'HELP_TOKENS_VERSION')
 
 ############## OPEN EDX ENTERPRISE SERVICE CONFIGURATION ######################
 # The Open edX Enterprise service is currently hosted via the LMS container/process.
diff --git a/lms/startup.py b/lms/startup.py
index 969093f34ac..9366269a9b6 100644
--- a/lms/startup.py
+++ b/lms/startup.py
@@ -12,7 +12,6 @@ from django.conf import settings
 settings.INSTALLED_APPS  # pylint: disable=pointless-statement
 
 from openedx.core.lib.django_startup import autostartup
-from openedx.core.release import doc_version
 
 from openedx.core.djangoapps.monkey_patch import django_db_models_options
 
@@ -73,10 +72,6 @@ def run():
     xmodule.x_module.descriptor_global_handler_url = lms_xblock.runtime.handler_url
     xmodule.x_module.descriptor_global_local_resource_url = lms_xblock.runtime.local_resource_url
 
-    # Set the version of docs that help-tokens will go to.
-    settings.HELP_TOKENS_LANGUAGE_CODE = settings.LANGUAGE_CODE
-    settings.HELP_TOKENS_VERSION = doc_version()
-
     # validate configurations on startup
     validate_lms_config(settings)
 
-- 
GitLab