Commit 6be4337c by Ned Batchelder Committed by GitHub

Merge pull request #14898 from edx/nedbat/help-tokens-app

Use a new external app for help tokens
parents 2b8020b6 55e04d2c
"""
Django Template Context Processor for CMS Online Contextual Help
"""
import ConfigParser
from django.conf import settings
from util.help_context_processor import common_doc_url
# Open and parse the configuration file when the module is initialized
CONFIG_FILE = open(settings.REPO_ROOT / "docs" / "cms_config.ini")
CONFIG = ConfigParser.ConfigParser()
CONFIG.readfp(CONFIG_FILE)
def doc_url(request=None): # pylint: disable=unused-argument
"""
This function is added in the list of TEMPLATES 'context_processors' OPTION, which is a django setting for
a tuple of callables that take a request object as their argument and return a dictionary of items
to be merged into the RequestContext.
This function returns a dict with get_online_help_info, making it directly available to all mako templates.
Args:
request: Currently not used, but is passed by django to context processors.
May be used in the future for determining the language of choice.
"""
return common_doc_url(request, CONFIG)
...@@ -496,4 +496,4 @@ AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE ...@@ -496,4 +496,4 @@ AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE
############## Settings for Studio Context Sensitive Help ############## ############## Settings for Studio Context Sensitive Help ##############
DOC_LINK_BASE_URL = ENV_TOKENS.get('DOC_LINK_BASE_URL', DOC_LINK_BASE_URL) HELP_TOKENS_BOOKS = ENV_TOKENS.get('HELP_TOKENS_BOOKS', HELP_TOKENS_BOOKS)
...@@ -13,6 +13,7 @@ from the same directory. ...@@ -13,6 +13,7 @@ from the same directory.
import os import os
from path import Path as path from path import Path as path
from openedx.core.release import RELEASE_LINE
########################## Prod-like settings ################################### ########################## Prod-like settings ###################################
# These should be as close as possible to the settings we use in production. # These should be as close as possible to the settings we use in production.
...@@ -124,6 +125,12 @@ MOCK_SEARCH_BACKING_FILE = ( ...@@ -124,6 +125,12 @@ MOCK_SEARCH_BACKING_FILE = (
SECRET_KEY = "very_secret_bok_choy_key" SECRET_KEY = "very_secret_bok_choy_key"
LMS_ROOT_URL = "http://localhost:8000" LMS_ROOT_URL = "http://localhost:8000"
if RELEASE_LINE == "master":
# On master, acceptance tests use edX books, not the default Open edX books.
HELP_TOKENS_BOOKS = {
'learner': 'http://edx.readthedocs.io/projects/edx-guide-for-students',
'course_author': 'http://edx.readthedocs.io/projects/edx-partner-course-staff',
}
##################################################################### #####################################################################
# Lastly, see if the developer has any local overrides. # Lastly, see if the developer has any local overrides.
......
...@@ -89,7 +89,8 @@ from lms.envs.common import ( ...@@ -89,7 +89,8 @@ from lms.envs.common import (
FILE_UPLOAD_STORAGE_BUCKET_NAME, FILE_UPLOAD_STORAGE_BUCKET_NAME,
FILE_UPLOAD_STORAGE_PREFIX, FILE_UPLOAD_STORAGE_PREFIX,
COURSE_ENROLLMENT_MODES COURSE_ENROLLMENT_MODES,
HELP_TOKENS_BOOKS,
) )
from path import Path as path from path import Path as path
from warnings import simplefilter from warnings import simplefilter
...@@ -300,7 +301,7 @@ TEMPLATES = [ ...@@ -300,7 +301,7 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth', # this is required for admin 'django.contrib.auth.context_processors.auth', # this is required for admin
'django.template.context_processors.csrf', 'django.template.context_processors.csrf',
'dealer.contrib.django.staff.context_processor', # access git revision 'dealer.contrib.django.staff.context_processor', # access git revision
'contentstore.context_processors.doc_url', 'help_tokens.context_processor',
), ),
# Change 'debug' in your environment settings files - not here. # Change 'debug' in your environment settings files - not here.
'debug': False 'debug': False
...@@ -1248,7 +1249,7 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id' ...@@ -1248,7 +1249,7 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
############## Settings for Studio Context Sensitive Help ############## ############## Settings for Studio Context Sensitive Help ##############
DOC_LINK_BASE_URL = None HELP_TOKENS_INI_FILE = REPO_ROOT / "docs" / "cms_config.ini"
# Theme directory locale paths # Theme directory locale paths
COMPREHENSIVE_THEME_LOCALE_PATHS = [] COMPREHENSIVE_THEME_LOCALE_PATHS = []
......
...@@ -12,6 +12,7 @@ from openedx.core.lib.django_startup import autostartup ...@@ -12,6 +12,7 @@ from openedx.core.lib.django_startup import autostartup
import django import django
from openedx.core.djangoapps.monkey_patch import django_db_models_options from openedx.core.djangoapps.monkey_patch import django_db_models_options
from openedx.core.lib.xblock_utils import xblock_local_resource_url from openedx.core.lib.xblock_utils import xblock_local_resource_url
from openedx.core.release import doc_version
import xmodule.x_module import xmodule.x_module
import cms.lib.xblock.runtime import cms.lib.xblock.runtime
...@@ -45,6 +46,10 @@ def run(): ...@@ -45,6 +46,10 @@ def run():
xmodule.x_module.descriptor_global_handler_url = cms.lib.xblock.runtime.handler_url 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 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 configurations on startup
validate_cms_config(settings) validate_cms_config(settings)
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from contentstore.context_processors import doc_url
%> %>
<div class="wrapper-header wrapper" id="view-top"> <div class="wrapper-header wrapper" id="view-top">
<header class="primary" role="banner"> <header class="primary" role="banner">
......
...@@ -62,6 +62,9 @@ urlpatterns = patterns( ...@@ -62,6 +62,9 @@ urlpatterns = patterns(
# Darklang View to change the preview language (or dark language) # Darklang View to change the preview language (or dark language)
url(r'^update_lang/', include('openedx.core.djangoapps.dark_lang.urls', namespace='dark_lang')), url(r'^update_lang/', include('openedx.core.djangoapps.dark_lang.urls', namespace='dark_lang')),
# For redirecting to help pages.
url(r'^help_token/', include('help_tokens.urls')),
) )
# restful api # restful api
......
"""
Common functionality for Django Template Context Processor for
Online Contextual Help.
"""
import ConfigParser
import logging
from django.conf import settings
from openedx.core.release import doc_version
log = logging.getLogger(__name__)
def common_doc_url(request, config_file_object): # pylint: disable=unused-argument
"""
This function is added in the list of TEMPLATES 'context_processors' OPTION, which is a django setting for
a tuple of callables that take a request object as their argument and return a dictionary of items
to be merged into the RequestContext.
This function returns a dict with get_online_help_info, making it directly available to all mako templates.
Args:
request: Currently not used, but is passed by django to context processors.
May be used in the future for determining the language of choice.
config_file_object: Configuration file object.
"""
def get_online_help_info(page_token=None):
"""
Args:
page_token: A string that identifies the page for which the help information is requested.
It should correspond to an option in the docs/config_file_object.ini file. If it doesn't, the "default"
option is used instead.
Returns:
A dict mapping the following items
* "doc_url" - a string with the url corresponding to the online help location for the given page_token.
* "pdf_url" - a string with the url corresponding to the location of the PDF help file.
"""
def get_config_value_with_default(section_name, option, default_option="default"):
"""
Args:
section_name: name of the section in the configuration from which the option should be found
option: name of the configuration option
default_option: name of the default configuration option whose value should be returned if the
requested option is not found
"""
if option:
try:
return config_file_object.get(section_name, option)
except (ConfigParser.NoOptionError, AttributeError):
log.debug("Didn't find a configuration option for '%s' section and '%s' option",
section_name, option)
return config_file_object.get(section_name, default_option)
def get_doc_url():
"""
Returns:
The URL for the documentation
"""
# Read an optional configuration property that sets the base
# URL of documentation links. By default, DOC_LINK_BASE_URL
# is null, this test determines whether it is set to a non-null
# value. If it is set, this funtion will use its string value
# as the base of documentation link URLs. If it is not set, the
# function reads the base of the documentation link URLs from
# the .ini configuration file, lms_config.ini or cms_config.ini.
if settings.DOC_LINK_BASE_URL:
doc_base_url = settings.DOC_LINK_BASE_URL
else:
doc_base_url = config_file_object.get("help_settings", "url_base")
# Construct and return the URL for the documentation link.
return "{url_base}/{language}/{version}/{page_path}".format(
url_base=doc_base_url,
language=get_config_value_with_default("locales", settings.LANGUAGE_CODE),
version=doc_version(),
page_path=get_config_value_with_default("pages", page_token),
)
def get_pdf_url():
"""
Returns:
The URL for the PDF document using the pdf_settings and the
help_settings (version) in the configuration
"""
# Read an optional configuration property that sets the base
# URL of pdf links. By default, DOC_LINK_BASE_URL
# is null, this test determines whether it is set to a non-null
# value. If it is set, this funtion will use its string value
# as the base of documentation link URLs. If it is not set, the
# function reads the base of the documentation link URLs from
# the .ini configuration file, lms_config.ini or cms_config.ini.
if settings.DOC_LINK_BASE_URL:
pdf_base_url = settings.DOC_LINK_BASE_URL
else:
pdf_base_url = config_file_object.get("pdf_settings", "pdf_base")
# Construct and return the URL for the PDF link.
return "{pdf_base}/{version}/{pdf_file}".format(
pdf_base=pdf_base_url,
version=doc_version(),
pdf_file=config_file_object.get("pdf_settings", "pdf_file"),
)
return {
"doc_url": get_doc_url(),
"pdf_url": get_pdf_url(),
}
return {'get_online_help_info': get_online_help_info}
"""
Tests for help_context_processor.py
"""
import ConfigParser
from mock import patch
from django.conf import settings
from django.test import TestCase
from openedx.core.release import doc_version
from util.help_context_processor import common_doc_url
CONFIG_FILE = open(settings.REPO_ROOT / "docs" / "lms_config.ini")
CONFIG = ConfigParser.ConfigParser()
CONFIG.readfp(CONFIG_FILE)
class HelpContextProcessorTest(TestCase):
"""
Tests for help_context_processor.py
"""
@staticmethod
def _get_doc_url(page_token=None):
""" Helper method for getting the doc url. """
return common_doc_url(None, CONFIG)['get_online_help_info'](page_token)['doc_url']
@staticmethod
def _get_pdf_url():
""" Helper method for getting the pdf url. """
return common_doc_url(None, CONFIG)['get_online_help_info']()['pdf_url']
def test_get_doc_url(self):
# Test default values.
doc = "http://edx.readthedocs.io/projects/open-edx-learner-guide/en/{}/index.html"
self.assertEqual(self._get_doc_url(), doc.format(doc_version()))
# Provide a known page_token.
doc = "http://edx.readthedocs.io/projects/open-edx-learner-guide/en/{}/SFD_dashboard_profile_SectionHead.html"
self.assertEqual(self._get_doc_url('profile'), doc.format(doc_version()))
# Use settings.DOC_LINK_BASE_URL to override default base_url.
doc = "settings_base_url/en/{}/SFD_instructor_dash_help.html"
with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'):
self.assertEqual(self._get_doc_url('instructor'), doc.format(doc_version()))
def test_get_pdf_url(self):
# Test default values.
doc = "https://media.readthedocs.org/pdf/open-edx-learner-guide/{}/open-edx-learner-guide.pdf"
self.assertEqual(self._get_pdf_url(), doc.format(doc_version()))
# Use settings.DOC_LINK_BASE_URL to override default base_url.
doc = "settings_base_url/{}/open-edx-learner-guide.pdf"
with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'):
self.assertEqual(self._get_pdf_url(), doc.format(doc_version()))
""" """
Test helper functions and base classes. Test helper functions and base classes.
""" """
import inspect import inspect
import json import json
import unittest import unittest
...@@ -13,6 +14,7 @@ import urlparse ...@@ -13,6 +14,7 @@ import urlparse
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime from datetime import datetime
from path import Path as path from path import Path as path
from bok_choy.javascript import js_defined from bok_choy.javascript import js_defined
from bok_choy.web_app_test import WebAppTest from bok_choy.web_app_test import WebAppTest
from bok_choy.promise import EmptyPromise, Promise from bok_choy.promise import EmptyPromise, Promise
...@@ -32,6 +34,7 @@ from selenium.webdriver.support.ui import WebDriverWait ...@@ -32,6 +34,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from unittest import TestCase from unittest import TestCase
from openedx.core.release import doc_version, RELEASE_LINE
from common.test.acceptance.pages.common import BASE_URL from common.test.acceptance.pages.common import BASE_URL
...@@ -428,7 +431,31 @@ def assert_opened_help_link_is_correct(test, url): ...@@ -428,7 +431,31 @@ def assert_opened_help_link_is_correct(test, url):
test.browser.switch_to_window(test.browser.window_handles[-1]) test.browser.switch_to_window(test.browser.window_handles[-1])
# Assert that url in the browser is the same. # Assert that url in the browser is the same.
test.assertEqual(url, test.browser.current_url) test.assertEqual(url, test.browser.current_url)
test.assertNotIn('Maze Found', test.browser.title) # Check that the URL loads. Can't do this in the browser because it might
# be loading a "Maze Found" missing content page.
response = requests.get(url)
test.assertEqual(response.status_code, 200, "URL {!r} returned {}".format(url, response.status_code))
EDX_BOOKS = {
'course_author': 'edx-partner-course-staff',
'learner': 'edx-guide-for-students',
}
OPEN_BOOKS = {
'course_author': 'open-edx-building-and-running-a-course',
'learner': 'open-edx-learner-guide',
}
def url_for_help(book_slug, path):
"""
Create a full help URL given a book slug and a path component.
"""
# Emulate the switch between books that happens in envs/bokchoy.py
books = EDX_BOOKS if RELEASE_LINE == "master" else OPEN_BOOKS
url = 'http://edx.readthedocs.io/projects/{}/en/{}{}'.format(books[book_slug], doc_version(), path)
return url
class EventsTestMixin(TestCase): class EventsTestMixin(TestCase):
......
""" """
Test Help links in LMS Test Help links in LMS
""" """
import json import json
from common.test.acceptance.tests.lms.test_lms_instructor_dashboard import BaseInstructorDashboardTest from common.test.acceptance.tests.lms.test_lms_instructor_dashboard import BaseInstructorDashboardTest
...@@ -11,11 +12,10 @@ from common.test.acceptance.fixtures.course import CourseFixture ...@@ -11,11 +12,10 @@ from common.test.acceptance.fixtures.course import CourseFixture
from common.test.acceptance.tests.helpers import ( from common.test.acceptance.tests.helpers import (
assert_link, assert_link,
assert_opened_help_link_is_correct assert_opened_help_link_is_correct,
url_for_help,
) )
from openedx.core.release import doc_version
class TestCohortHelp(ContainerBase): class TestCohortHelp(ContainerBase):
""" """
...@@ -34,13 +34,8 @@ class TestCohortHelp(ContainerBase): ...@@ -34,13 +34,8 @@ class TestCohortHelp(ContainerBase):
Arguments: Arguments:
href (str): Help url href (str): Help url
""" """
expected_link = {
'href': href,
'text': 'What does this mean?'
}
actual_link = self.cohort_management.get_cohort_help_element_and_click_help() actual_link = self.cohort_management.get_cohort_help_element_and_click_help()
self.assertEqual(actual_link.text, "What does this mean?")
assert_link(self, expected_link, actual_link)
assert_opened_help_link_is_correct(self, href) assert_opened_help_link_is_correct(self, href)
def test_manual_cohort_help(self): def test_manual_cohort_help(self):
...@@ -57,11 +52,10 @@ class TestCohortHelp(ContainerBase): ...@@ -57,11 +52,10 @@ class TestCohortHelp(ContainerBase):
""" """
self.cohort_management.add_cohort('cohort_name') self.cohort_management.add_cohort('cohort_name')
href = ( href = url_for_help(
'http://edx.readthedocs.io/projects/edx-partner-course-staff/en/{}/' 'course_author',
'course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually' '/course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually',
).format(doc_version()) )
self.verify_help_link(href) self.verify_help_link(href)
def test_automatic_cohort_help(self): def test_automatic_cohort_help(self):
...@@ -79,11 +73,10 @@ class TestCohortHelp(ContainerBase): ...@@ -79,11 +73,10 @@ class TestCohortHelp(ContainerBase):
self.cohort_management.add_cohort('cohort_name', assignment_type='random') self.cohort_management.add_cohort('cohort_name', assignment_type='random')
href = ( href = url_for_help(
'http://edx.readthedocs.io/projects/edx-partner-course-staff/en/{}/' 'course_author',
'course_features/cohorts/cohorts_overview.html#all-automated-assignment' '/course_features/cohorts/cohorts_overview.html#all-automated-assignment',
).format(doc_version()) )
self.verify_help_link(href) self.verify_help_link(href)
def enable_cohorting(self, course_fixture): def enable_cohorting(self, course_fixture):
...@@ -114,8 +107,6 @@ class InstructorDashboardHelp(BaseInstructorDashboardTest): ...@@ -114,8 +107,6 @@ class InstructorDashboardHelp(BaseInstructorDashboardTest):
When I click "Help" When I click "Help"
Then I see help about the instructor dashboard in a new tab Then I see help about the instructor dashboard in a new tab
""" """
href = ( href = url_for_help('learner', '/SFD_instructor_dash_help.html')
'http://edx.readthedocs.io/projects/edx-guide-for-students/en/{}/SFD_instructor_dash_help.html'
).format(doc_version())
self.instructor_dashboard_page.click_help() self.instructor_dashboard_page.click_help()
assert_opened_help_link_is_correct(self, href) assert_opened_help_link_is_correct(self, href)
# below are the server-wide settings for documentation
[help_settings]
# The optional DOC_LINK_BASE_URL configuration property will override url_base
url_base = http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course
# below are the pdf settings for the pdf file
[pdf_settings]
pdf_base = https://media.readthedocs.org/pdf/edx-partner-course-staff
pdf_file = edx-partner-course-staff.pdf
# below are the sub-paths to the documentation for the various pages # below are the sub-paths to the documentation for the various pages
# NOTE: If any of these page settings change, then their corresponding test should be updated # NOTE: If any of these page settings change, then their corresponding test should be updated
# in edx-platform/common/test/acceptance/tests/studio/test_studio.help.py # in edx-platform/common/test/acceptance/tests/studio/test_studio.help.py
[pages] [pages]
default = index.html default = course_author:index.html
home = getting_started/CA_get_started_Studio.html home = course_author:getting_started/CA_get_started_Studio.html
develop_course = developing_course/index.html develop_course = course_author:developing_course/index.html
outline = developing_course/course_outline.html outline = course_author:developing_course/course_outline.html
unit = developing_course/course_units.html unit = course_author:developing_course/course_units.html
visibility = developing_course/controlling_content_visibility.html visibility = course_author:developing_course/controlling_content_visibility.html
updates = course_assets/handouts_updates.html updates = course_author:course_assets/handouts_updates.html
pages = course_assets/pages.html pages = course_author:course_assets/pages.html
files = course_assets/course_files.html files = course_author:course_assets/course_files.html
textbooks = course_assets/textbooks.html textbooks = course_author:course_assets/textbooks.html
schedule = set_up_course/setting_up_student_view.html schedule = course_author:set_up_course/setting_up_student_view.html
grading = grading/index.html grading = course_author:grading/index.html
team_course = set_up_course/course_staffing.html#add-course-team-members team_course = course_author:set_up_course/course_staffing.html#add-course-team-members
team_library = course_components/libraries.html#give-other-users-access-to-your-library team_library = course_author:course_components/libraries.html#give-other-users-access-to-your-library
advanced = index.html advanced = course_author:index.html
checklist = set_up_course/creating_new_course.html checklist = course_author:set_up_course/creating_new_course.html
import_library = course_components/libraries.html#import-a-library import_library = course_author:course_components/libraries.html#import-a-library
import_course = releasing_course/export_import_course.html#import-a-course import_course = course_author:releasing_course/export_import_course.html#import-a-course
export_library = course_components/libraries.html#export-a-library export_library = course_author:course_components/libraries.html#export-a-library
export_course = releasing_course/export_import_course.html#export-a-course export_course = course_author:releasing_course/export_import_course.html#export-a-course
welcome = getting_started/index.html welcome = course_author:getting_started/index.html
login = getting_started/index.html login = course_author:getting_started/index.html
register = getting_started/index.html register = course_author:getting_started/index.html
content_libraries = course_components/libraries.html content_libraries = course_author:course_components/libraries.html
content_groups = course_features/cohorts/cohorted_courseware.html content_groups = course_author:course_features/cohorts/cohorted_courseware.html
enrollment_tracks = course_features/cohorts/cohorted_courseware.html enrollment_tracks = course_author:course_features/cohorts/cohorted_courseware.html
group_configurations = course_features/content_experiments/content_experiments_configure.html#set-up-group-configurations-in-edx-studio group_configurations = course_author:course_features/content_experiments/content_experiments_configure.html#set-up-group-configurations-in-edx-studio
container = developing_course/course_components.html#components-that-contain-other-components container = course_author:developing_course/course_components.html#components-that-contain-other-components
video = video/video_uploads.html video = course_author:video/video_uploads.html
certificates = set_up_course/creating_course_certificates.html certificates = course_author:set_up_course/creating_course_certificates.html
# below are the language directory names for the different locales # below are the language directory names for the different locales
[locales] [locales]
......
# below are the server-wide settings for documentation
[help_settings]
# The optional DOC_LINK_BASE_URL configuration property will override url_base
url_base = http://edx.readthedocs.io/projects/open-edx-learner-guide
# below are the pdf settings for the pdf file
[pdf_settings]
pdf_base = https://media.readthedocs.org/pdf/open-edx-learner-guide
pdf_file = open-edx-learner-guide.pdf
# below are the sub-paths to the documentation for the various pages # below are the sub-paths to the documentation for the various pages
# NOTE: If any of these page settings change, then their corresponding test should be updated # NOTE: If any of these page settings change, then their corresponding test should be updated
# in edx-platform/common/test/acceptance/tests/lms/test_lms_help.py # in edx-platform/common/test/acceptance/tests/lms/test_lms_help.py
[pages] [pages]
default = index.html default = learner:index.html
instructor = learner:SFD_instructor_dash_help.html
instructor = SFD_instructor_dash_help.html course = learner:index.html
profile = learner:SFD_dashboard_profile_SectionHead.html
course = index.html dashboard = learner:SFD_dashboard_profile_SectionHead.html
courseinfo = learner:SFD_start_course.html
profile = SFD_dashboard_profile_SectionHead.html progress = learner:SFD_check_progress.html
learneraccountsettings = learner:SFD_update_acct_settings.html
dashboard = SFD_dashboard_profile_SectionHead.html learnerdashboard = learner:SFD_dashboard_profile_SectionHead.html
programs = learner:SFD_enrolling.html
courseinfo = SFD_start_course.html bookmarks = learner:SFD_bookmarks.html
notes = learner:SFD_notes.html
progress = SFD_check_progress.html wiki = learner:SFD_wiki.html
discussions = learner:sfd_discussions/index.html
learneraccountsettings = SFD_update_acct_settings.html
cohortmanual = course_author:course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually
learnerdashboard = SFD_dashboard_profile_SectionHead.html cohortautomatic = course_author:course_features/cohorts/cohorts_overview.html#all-automated-assignment
programs = SFD_enrolling.html
bookmarks = SFD_bookmarks.html
notes = SFD_notes.html
wiki = SFD_wiki.html
discussions = sfd_discussions/index.html
# below are the language directory names for the different locales # below are the language directory names for the different locales
[locales] [locales]
......
"""
Django Template Context Processor for LMS Online Contextual Help
"""
import ConfigParser
from django.conf import settings
from util.help_context_processor import common_doc_url
# Open and parse the configuration file when the module is initialized
CONFIG_FILE = open(settings.REPO_ROOT / "docs" / "lms_config.ini")
CONFIG = ConfigParser.ConfigParser()
CONFIG.readfp(CONFIG_FILE)
def doc_url(request=None): # pylint: disable=unused-argument
"""
This function is added in the list of TEMPLATES 'context_processors' OPTION, which is a django setting for
a tuple of callables that take a request object as their argument and return a dictionary of items
to be merged into the RequestContext.
This function returns a dict with get_online_help_info, making it directly available to all mako templates.
Args:
request: Currently not used, but is passed by django to context processors.
May be used in the future for determining the language of choice.
"""
return common_doc_url(request, CONFIG)
...@@ -899,7 +899,7 @@ AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE ...@@ -899,7 +899,7 @@ AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE
############## Settings for LMS Context Sensitive Help ############## ############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL = ENV_TOKENS.get('DOC_LINK_BASE_URL', DOC_LINK_BASE_URL) HELP_TOKENS_BOOKS = ENV_TOKENS.get('HELP_TOKENS_BOOKS', HELP_TOKENS_BOOKS)
############## OPEN EDX ENTERPRISE SERVICE CONFIGURATION ###################### ############## OPEN EDX ENTERPRISE SERVICE CONFIGURATION ######################
......
...@@ -14,6 +14,8 @@ import os ...@@ -14,6 +14,8 @@ import os
from path import Path as path from path import Path as path
from tempfile import mkdtemp from tempfile import mkdtemp
from openedx.core.release import RELEASE_LINE
CONFIG_ROOT = path(__file__).abspath().dirname() CONFIG_ROOT = path(__file__).abspath().dirname()
TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root"
...@@ -223,7 +225,12 @@ BADGING_BACKEND = 'lms.djangoapps.badges.backends.tests.dummy_backend.DummyBacke ...@@ -223,7 +225,12 @@ BADGING_BACKEND = 'lms.djangoapps.badges.backends.tests.dummy_backend.DummyBacke
ECOMMERCE_API_URL = 'http://localhost:8043/api/v2/' ECOMMERCE_API_URL = 'http://localhost:8043/api/v2/'
LMS_ROOT_URL = "http://localhost:8000" LMS_ROOT_URL = "http://localhost:8000"
DOC_LINK_BASE_URL = 'http://edx.readthedocs.io/projects/edx-guide-for-students' if RELEASE_LINE == "master":
# On master, acceptance tests use edX books, not the default Open edX books.
HELP_TOKENS_BOOKS = {
'learner': 'http://edx.readthedocs.io/projects/edx-guide-for-students',
'course_author': 'http://edx.readthedocs.io/projects/edx-partner-course-staff',
}
# TODO: TNL-6546: Remove this waffle and flag code. # TODO: TNL-6546: Remove this waffle and flag code.
from django.db.utils import ProgrammingError from django.db.utils import ProgrammingError
......
...@@ -547,7 +547,7 @@ TEMPLATES = [ ...@@ -547,7 +547,7 @@ TEMPLATES = [
'edxmako.shortcuts.footer_context_processor', 'edxmako.shortcuts.footer_context_processor',
# Online contextual help # Online contextual help
'context_processors.doc_url', 'help_tokens.context_processor',
'openedx.core.djangoapps.site_configuration.context_processors.configuration_context' 'openedx.core.djangoapps.site_configuration.context_processors.configuration_context'
], ],
# Change 'debug' in your environment settings files - not here. # Change 'debug' in your environment settings files - not here.
...@@ -3110,7 +3110,11 @@ REDIRECT_CACHE_KEY_PREFIX = 'redirects' ...@@ -3110,7 +3110,11 @@ REDIRECT_CACHE_KEY_PREFIX = 'redirects'
############## Settings for LMS Context Sensitive Help ############## ############## Settings for LMS Context Sensitive Help ##############
DOC_LINK_BASE_URL = None HELP_TOKENS_INI_FILE = REPO_ROOT / "docs" / "lms_config.ini"
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',
}
############## OPEN EDX ENTERPRISE SERVICE CONFIGURATION ###################### ############## OPEN EDX ENTERPRISE SERVICE CONFIGURATION ######################
# The Open edX Enterprise service is currently hosted via the LMS container/process. # The Open edX Enterprise service is currently hosted via the LMS container/process.
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
Module for code that should run during LMS startup Module for code that should run during LMS startup
""" """
import logging
import django import django
from django.conf import settings from django.conf import settings
...@@ -10,7 +12,7 @@ from django.conf import settings ...@@ -10,7 +12,7 @@ from django.conf import settings
settings.INSTALLED_APPS # pylint: disable=pointless-statement settings.INSTALLED_APPS # pylint: disable=pointless-statement
from openedx.core.lib.django_startup import autostartup from openedx.core.lib.django_startup import autostartup
import logging from openedx.core.release import doc_version
import analytics import analytics
from openedx.core.djangoapps.monkey_patch import django_db_models_options from openedx.core.djangoapps.monkey_patch import django_db_models_options
...@@ -79,6 +81,10 @@ def run(): ...@@ -79,6 +81,10 @@ def run():
xmodule.x_module.descriptor_global_handler_url = lms_xblock.runtime.handler_url 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 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 configurations on startup
validate_lms_config(settings) validate_lms_config(settings)
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<div class="setup-value"> <div class="setup-value">
<% if (cohort.get('assignment_type') == "manual") { %> <% if (cohort.get('assignment_type') == "manual") { %>
<%- gettext("Learners are added to this cohort only when you provide their email addresses or usernames on this page.") %> <%- gettext("Learners are added to this cohort only when you provide their email addresses or usernames on this page.") %>
<a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually" class="incontext-help action-secondary action-help" target="_blank"><%- gettext("What does this mean?") %></a> <a href="/help_token/cohortmanual" class="incontext-help action-secondary action-help" target="_blank"><%- gettext("What does this mean?") %></a>
<% } else { %> <% } else { %>
<%- gettext("Learners are added to this cohort automatically.") %> <%- gettext("Learners are added to this cohort automatically.") %>
<a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/course_features/cohorts/cohorts_overview.html#all-automated-assignment" class="incontext-help action-secondary action-help" target="_blank"><%- gettext("What does this mean?") %></a> <a href="/help_token/cohortautomatic" class="incontext-help action-secondary action-help" target="_blank"><%- gettext("What does this mean?") %></a>
<% } %> <% } %>
</div> </div>
</div> </div>
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from context_processors import doc_url
from lms.djangoapps.ccx.overrides import get_current_ccx from lms.djangoapps.ccx.overrides import get_current_ccx
from openedx.core.djangolib.markup import HTML, Text from openedx.core.djangolib.markup import HTML, Text
......
...@@ -101,6 +101,9 @@ urlpatterns = ( ...@@ -101,6 +101,9 @@ urlpatterns = (
# URLs for managing dark launches of languages # URLs for managing dark launches of languages
url(r'^update_lang/', include('openedx.core.djangoapps.dark_lang.urls', namespace='dark_lang')), url(r'^update_lang/', include('openedx.core.djangoapps.dark_lang.urls', namespace='dark_lang')),
# For redirecting to help pages.
url(r'^help_token/', include('help_tokens.urls')),
# URLs for API access management # URLs for API access management
url(r'^api-admin/', include('openedx.core.djangoapps.api_admin.urls', namespace='api_admin')), url(r'^api-admin/', include('openedx.core.djangoapps.api_admin.urls', namespace='api_admin')),
) )
......
...@@ -89,6 +89,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.5#egg=xblock-utils==1.0.5 ...@@ -89,6 +89,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.5#egg=xblock-utils==1.0.5
git+https://github.com/edx/edx-user-state-client.git@1.0.1#egg=edx-user-state-client==1.0.1 git+https://github.com/edx/edx-user-state-client.git@1.0.1#egg=edx-user-state-client==1.0.1
git+https://github.com/edx/xblock-lti-consumer.git@v1.1.3#egg=lti_consumer-xblock==1.1.3 git+https://github.com/edx/xblock-lti-consumer.git@v1.1.3#egg=lti_consumer-xblock==1.1.3
git+https://github.com/edx/edx-proctoring.git@0.18.0#egg=edx-proctoring==0.18.0 git+https://github.com/edx/edx-proctoring.git@0.18.0#egg=edx-proctoring==0.18.0
git+https://github.com/edx/help-tokens.git@v1.0.0#egg=help-tokens==1.0.0
# Third Party XBlocks # Third Party XBlocks
git+https://github.com/open-craft/xblock-poll@v1.2.6#egg=xblock-poll==1.2.6 git+https://github.com/open-craft/xblock-poll@v1.2.6#egg=xblock-poll==1.2.6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment