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
############## 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.
import os
from path import Path as path
from openedx.core.release import RELEASE_LINE
########################## Prod-like settings ###################################
# These should be as close as possible to the settings we use in production.
......@@ -124,6 +125,12 @@ MOCK_SEARCH_BACKING_FILE = (
SECRET_KEY = "very_secret_bok_choy_key"
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.
......
......@@ -89,7 +89,8 @@ from lms.envs.common import (
FILE_UPLOAD_STORAGE_BUCKET_NAME,
FILE_UPLOAD_STORAGE_PREFIX,
COURSE_ENROLLMENT_MODES
COURSE_ENROLLMENT_MODES,
HELP_TOKENS_BOOKS,
)
from path import Path as path
from warnings import simplefilter
......@@ -300,7 +301,7 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth', # this is required for admin
'django.template.context_processors.csrf',
'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.
'debug': False
......@@ -1248,7 +1249,7 @@ AFFILIATE_COOKIE_NAME = 'affiliate_id'
############## 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
COMPREHENSIVE_THEME_LOCALE_PATHS = []
......
......@@ -12,6 +12,7 @@ from openedx.core.lib.django_startup import autostartup
import django
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.release import doc_version
import xmodule.x_module
import cms.lib.xblock.runtime
......@@ -45,6 +46,10 @@ 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)
......
......@@ -4,7 +4,6 @@
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from contentstore.context_processors import doc_url
%>
<div class="wrapper-header wrapper" id="view-top">
<header class="primary" role="banner">
......
......@@ -62,6 +62,9 @@ urlpatterns = patterns(
# Darklang View to change the preview language (or dark language)
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
......
"""
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.
"""
import inspect
import json
import unittest
......@@ -13,6 +14,7 @@ import urlparse
from contextlib import contextmanager
from datetime import datetime
from path import Path as path
from bok_choy.javascript import js_defined
from bok_choy.web_app_test import WebAppTest
from bok_choy.promise import EmptyPromise, Promise
......@@ -32,6 +34,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from unittest import TestCase
from openedx.core.release import doc_version, RELEASE_LINE
from common.test.acceptance.pages.common import BASE_URL
......@@ -428,7 +431,31 @@ def assert_opened_help_link_is_correct(test, url):
test.browser.switch_to_window(test.browser.window_handles[-1])
# Assert that url in the browser is the same.
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):
......
"""
Test Help links in LMS
"""
import json
from common.test.acceptance.tests.lms.test_lms_instructor_dashboard import BaseInstructorDashboardTest
......@@ -11,11 +12,10 @@ from common.test.acceptance.fixtures.course import CourseFixture
from common.test.acceptance.tests.helpers import (
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):
"""
......@@ -34,13 +34,8 @@ class TestCohortHelp(ContainerBase):
Arguments:
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()
assert_link(self, expected_link, actual_link)
self.assertEqual(actual_link.text, "What does this mean?")
assert_opened_help_link_is_correct(self, href)
def test_manual_cohort_help(self):
......@@ -57,11 +52,10 @@ class TestCohortHelp(ContainerBase):
"""
self.cohort_management.add_cohort('cohort_name')
href = (
'http://edx.readthedocs.io/projects/edx-partner-course-staff/en/{}/'
'course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually'
).format(doc_version())
href = url_for_help(
'course_author',
'/course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually',
)
self.verify_help_link(href)
def test_automatic_cohort_help(self):
......@@ -79,11 +73,10 @@ class TestCohortHelp(ContainerBase):
self.cohort_management.add_cohort('cohort_name', assignment_type='random')
href = (
'http://edx.readthedocs.io/projects/edx-partner-course-staff/en/{}/'
'course_features/cohorts/cohorts_overview.html#all-automated-assignment'
).format(doc_version())
href = url_for_help(
'course_author',
'/course_features/cohorts/cohorts_overview.html#all-automated-assignment',
)
self.verify_help_link(href)
def enable_cohorting(self, course_fixture):
......@@ -114,8 +107,6 @@ class InstructorDashboardHelp(BaseInstructorDashboardTest):
When I click "Help"
Then I see help about the instructor dashboard in a new tab
"""
href = (
'http://edx.readthedocs.io/projects/edx-guide-for-students/en/{}/SFD_instructor_dash_help.html'
).format(doc_version())
href = url_for_help('learner', '/SFD_instructor_dash_help.html')
self.instructor_dashboard_page.click_help()
assert_opened_help_link_is_correct(self, href)
......@@ -29,33 +29,24 @@ from common.test.acceptance.pages.studio.users import CourseTeamPage
from common.test.acceptance.tests.helpers import (
AcceptanceTest,
assert_nav_help_link,
assert_side_bar_help_link
assert_side_bar_help_link,
url_for_help,
)
from common.test.acceptance.pages.studio.import_export import ExportLibraryPage, ImportLibraryPage
from common.test.acceptance.pages.studio.auto_auth import AutoAuthPage
from openedx.core.release import doc_version
DOCUMENTATION_URL_TEMPLATE = (
'http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/{doc_version}{path}'
)
def _get_expected_documentation_url(path):
"""
Returns the expected URL for the building and running a course documentation.
"""
return DOCUMENTATION_URL_TEMPLATE.format(
doc_version=doc_version(),
path=path,
)
return url_for_help('course_author', path)
@attr(shard=10)
class StudioHelpTest(StudioCourseTest):
"""Tests for Studio help."""
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_studio_help_links(self):
"""Test that the help links are present and have the correct content."""
page = DashboardPage(self.browser)
......@@ -102,7 +93,6 @@ class SignInHelpTest(AcceptanceTest):
self.index_page = IndexPage(self.browser)
self.index_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_sign_in_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Sign In' page.
......@@ -113,7 +103,7 @@ class SignInHelpTest(AcceptanceTest):
And help url should be correct
"""
sign_in_page = self.index_page.click_sign_in()
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/index.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -134,7 +124,6 @@ class SignUpHelpTest(AcceptanceTest):
self.index_page = IndexPage(self.browser)
self.index_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_sign_up_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Sign Up' page.
......@@ -145,7 +134,7 @@ class SignUpHelpTest(AcceptanceTest):
And help url should be correct
"""
sign_up_page = self.index_page.click_sign_up()
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/index.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -166,7 +155,6 @@ class HomeHelpTest(StudioCourseTest):
self.home_page = HomePage(self.browser)
self.home_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_home_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page.
......@@ -176,7 +164,7 @@ class HomeHelpTest(StudioCourseTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -185,7 +173,6 @@ class HomeHelpTest(StudioCourseTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_home_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on 'Home'(Courses tab) page.
......@@ -195,7 +182,7 @@ class HomeHelpTest(StudioCourseTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_side_bar_help_link(
......@@ -221,7 +208,6 @@ class NewCourseHelpTest(AcceptanceTest):
self.assertTrue(self.dashboard_page.new_course_button.present)
self.dashboard_page.click_new_course_button()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_create_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Create a New Course' page in the dashboard.
......@@ -231,7 +217,7 @@ class NewCourseHelpTest(AcceptanceTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -240,7 +226,6 @@ class NewCourseHelpTest(AcceptanceTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_create_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on 'Create a New Course' page in the dashboard.
......@@ -250,7 +235,7 @@ class NewCourseHelpTest(AcceptanceTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_side_bar_help_link(
......@@ -276,7 +261,6 @@ class NewLibraryHelpTest(AcceptanceTest):
self.assertTrue(self.dashboard_page.has_new_library_button)
self.dashboard_page.click_new_library()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_create_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Create a New Library' page in the dashboard.
......@@ -286,7 +270,7 @@ class NewLibraryHelpTest(AcceptanceTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -295,7 +279,6 @@ class NewLibraryHelpTest(AcceptanceTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_create_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on 'Create a New Library' page in the dashboard.
......@@ -305,7 +288,7 @@ class NewLibraryHelpTest(AcceptanceTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_side_bar_help_link(
......@@ -329,7 +312,6 @@ class LibraryTabHelpTest(AcceptanceTest):
self.auth_page.visit()
self.dashboard_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_tab_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Home'(Courses tab) page.
......@@ -341,7 +323,7 @@ class LibraryTabHelpTest(AcceptanceTest):
"""
self.assertTrue(self.dashboard_page.has_new_library_button)
click_css(self.dashboard_page, '#course-index-tabs .libraries-tab', 0, False)
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/CA_get_started_Studio.html')
# Assert that help link is correct.
assert_nav_help_link(
......@@ -361,7 +343,6 @@ class LibraryHelpTest(StudioLibraryTest):
self.library_page = LibraryPage(self.browser, self.library_key)
self.library_user_page = LibraryUsersPage(self.browser, self.library_key)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_content_nav_help(self):
"""
Scenario: Help link in navigation bar is working on content
......@@ -382,7 +363,6 @@ class LibraryHelpTest(StudioLibraryTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_content_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on
......@@ -404,7 +384,6 @@ class LibraryHelpTest(StudioLibraryTest):
help_text='Learn more about content libraries'
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_user_access_setting_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'User Access'
......@@ -438,7 +417,6 @@ class LibraryImportHelpTest(StudioLibraryTest):
self.library_import_page = ImportLibraryPage(self.browser, self.library_key)
self.library_import_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_import_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Library import page.
......@@ -457,7 +435,6 @@ class LibraryImportHelpTest(StudioLibraryTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_import_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on Library import page.
......@@ -488,7 +465,6 @@ class LibraryExportHelpTest(StudioLibraryTest):
self.library_export_page = ExportLibraryPage(self.browser, self.library_key)
self.library_export_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_export_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Library export page.
......@@ -507,7 +483,6 @@ class LibraryExportHelpTest(StudioLibraryTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_library_export_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on Library export page.
......@@ -562,7 +537,6 @@ class CourseOutlineHelpTest(StudioCourseTest):
href=expected_url
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_outline_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on Course Outline page
......@@ -599,7 +573,6 @@ class CourseUpdateHelpTest(StudioCourseTest):
)
self.course_update_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_update_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Course Update' page
......@@ -634,7 +607,6 @@ class AssetIndexHelpTest(StudioCourseTest):
)
self.course_asset_index_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_asset_index_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Files & Uploads' page
......@@ -653,7 +625,6 @@ class AssetIndexHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_asset_index_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on 'Files & Uploads' page
......@@ -689,7 +660,6 @@ class CoursePagesHelpTest(StudioCourseTest):
)
self.course_pages_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_page_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Pages' page
......@@ -724,7 +694,6 @@ class UploadTextbookHelpTest(StudioCourseTest):
)
self.course_textbook_upload_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_textbook_upload_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Textbooks' page
......@@ -743,7 +712,6 @@ class UploadTextbookHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_textbook_side_bar_help(self):
"""
Scenario: Help link in sidebar links is working on 'Textbooks' page
......@@ -793,7 +761,6 @@ class StudioUnitHelpTest(ContainerBase):
)
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_unit_page_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Unit page.
......@@ -831,7 +798,6 @@ class SettingsHelpTest(StudioCourseTest):
self.settings_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_settings_page_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Settings page.
......@@ -868,7 +834,6 @@ class GradingPageHelpTest(StudioCourseTest):
self.grading_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_grading_page_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Grading page.
......@@ -905,7 +870,6 @@ class CourseTeamSettingsHelpTest(StudioCourseTest):
self.course_team_settings_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_course_team_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Course Team settings page
......@@ -942,7 +906,6 @@ class CourseGroupConfigurationHelpTest(StudioCourseTest):
self.course_group_configuration_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_group_conf_nav_help(self):
"""
Scenario: Help link in navigation bar is working on
......@@ -962,7 +925,6 @@ class CourseGroupConfigurationHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_group_conf_content_group_side_bar_help(self):
"""
Scenario: Help link in side bar under the 'content group' is working
......@@ -1001,7 +963,6 @@ class AdvancedSettingHelpTest(StudioCourseTest):
self.advanced_settings.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_advanced_settings_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Advanced Settings page.
......@@ -1038,7 +999,6 @@ class CertificatePageHelpTest(StudioCourseTest):
self.certificates_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_certificate_page_nav_help(self):
"""
Scenario: Help link in navigation bar is working on Certificate settings page
......@@ -1057,7 +1017,6 @@ class CertificatePageHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_certificate_page_side_bar_help(self):
"""
Scenario: Help link in side bar is working Certificate settings page
......@@ -1107,7 +1066,6 @@ class GroupExperimentConfigurationHelpTest(ContainerBase):
{u"advanced_modules": {"value": ["split_test"]}}
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_course_group_configuration_experiment_side_bar_help(self):
"""
Scenario: Help link in side bar under the 'Experiment Group Configurations'
......@@ -1149,7 +1107,6 @@ class ToolsImportHelpTest(StudioCourseTest):
)
self.import_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_tools_import_nav_help(self):
"""
Scenario: Help link in navigation bar is working on tools Library import page
......@@ -1168,7 +1125,6 @@ class ToolsImportHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_tools_import_side_bar_help(self):
"""
Scenario: Help link in side bar is working on tools Library import page
......@@ -1206,7 +1162,6 @@ class ToolsExportHelpTest(StudioCourseTest):
)
self.export_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_tools_import_nav_help(self):
"""
Scenario: Help link in navigation bar is working on tools Library export page
......@@ -1225,7 +1180,6 @@ class ToolsExportHelpTest(StudioCourseTest):
href=expected_url,
)
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_tools_import_side_bar_help(self):
"""
Scenario: Help link in side bar is working on tools Library export page
......@@ -1256,7 +1210,6 @@ class StudioWelcomeHelpTest(AcceptanceTest):
self.index_page = IndexPage(self.browser)
self.index_page.visit()
@skip("Disabled as edx.org help links are now different than Open edX (@catong can advise)")
def test_welcome_nav_help(self):
"""
Scenario: Help link in navigation bar is working on 'Welcome' page (User not logged in).
......@@ -1266,7 +1219,7 @@ class StudioWelcomeHelpTest(AcceptanceTest):
Then Help link should open.
And help url should be correct
"""
expected_url = _get_expected_documentation_url('/get_started.html')
expected_url = _get_expected_documentation_url('/getting_started/index.html')
# Assert that help link is correct.
assert_nav_help_link(
......
# 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
# 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
[pages]
default = index.html
home = getting_started/CA_get_started_Studio.html
develop_course = developing_course/index.html
outline = developing_course/course_outline.html
unit = developing_course/course_units.html
visibility = developing_course/controlling_content_visibility.html
updates = course_assets/handouts_updates.html
pages = course_assets/pages.html
files = course_assets/course_files.html
textbooks = course_assets/textbooks.html
schedule = set_up_course/setting_up_student_view.html
grading = grading/index.html
team_course = set_up_course/course_staffing.html#add-course-team-members
team_library = course_components/libraries.html#give-other-users-access-to-your-library
advanced = index.html
checklist = set_up_course/creating_new_course.html
import_library = course_components/libraries.html#import-a-library
import_course = releasing_course/export_import_course.html#import-a-course
export_library = course_components/libraries.html#export-a-library
export_course = releasing_course/export_import_course.html#export-a-course
welcome = getting_started/index.html
login = getting_started/index.html
register = getting_started/index.html
content_libraries = course_components/libraries.html
content_groups = course_features/cohorts/cohorted_courseware.html
enrollment_tracks = course_features/cohorts/cohorted_courseware.html
group_configurations = 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
video = video/video_uploads.html
certificates = set_up_course/creating_course_certificates.html
default = course_author:index.html
home = course_author:getting_started/CA_get_started_Studio.html
develop_course = course_author:developing_course/index.html
outline = course_author:developing_course/course_outline.html
unit = course_author:developing_course/course_units.html
visibility = course_author:developing_course/controlling_content_visibility.html
updates = course_author:course_assets/handouts_updates.html
pages = course_author:course_assets/pages.html
files = course_author:course_assets/course_files.html
textbooks = course_author:course_assets/textbooks.html
schedule = course_author:set_up_course/setting_up_student_view.html
grading = course_author:grading/index.html
team_course = course_author:set_up_course/course_staffing.html#add-course-team-members
team_library = course_author:course_components/libraries.html#give-other-users-access-to-your-library
advanced = course_author:index.html
checklist = course_author:set_up_course/creating_new_course.html
import_library = course_author:course_components/libraries.html#import-a-library
import_course = course_author:releasing_course/export_import_course.html#import-a-course
export_library = course_author:course_components/libraries.html#export-a-library
export_course = course_author:releasing_course/export_import_course.html#export-a-course
welcome = course_author:getting_started/index.html
login = course_author:getting_started/index.html
register = course_author:getting_started/index.html
content_libraries = course_author:course_components/libraries.html
content_groups = course_author:course_features/cohorts/cohorted_courseware.html
enrollment_tracks = course_author:course_features/cohorts/cohorted_courseware.html
group_configurations = course_author:course_features/content_experiments/content_experiments_configure.html#set-up-group-configurations-in-edx-studio
container = course_author:developing_course/course_components.html#components-that-contain-other-components
video = course_author:video/video_uploads.html
certificates = course_author:set_up_course/creating_course_certificates.html
# below are the language directory names for the different 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
# 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
[pages]
default = index.html
instructor = SFD_instructor_dash_help.html
course = index.html
profile = SFD_dashboard_profile_SectionHead.html
dashboard = SFD_dashboard_profile_SectionHead.html
courseinfo = SFD_start_course.html
progress = SFD_check_progress.html
learneraccountsettings = SFD_update_acct_settings.html
learnerdashboard = SFD_dashboard_profile_SectionHead.html
programs = SFD_enrolling.html
bookmarks = SFD_bookmarks.html
notes = SFD_notes.html
wiki = SFD_wiki.html
discussions = sfd_discussions/index.html
default = learner:index.html
instructor = learner:SFD_instructor_dash_help.html
course = learner:index.html
profile = learner:SFD_dashboard_profile_SectionHead.html
dashboard = learner:SFD_dashboard_profile_SectionHead.html
courseinfo = learner:SFD_start_course.html
progress = learner:SFD_check_progress.html
learneraccountsettings = learner:SFD_update_acct_settings.html
learnerdashboard = learner:SFD_dashboard_profile_SectionHead.html
programs = learner:SFD_enrolling.html
bookmarks = learner:SFD_bookmarks.html
notes = learner:SFD_notes.html
wiki = learner:SFD_wiki.html
discussions = learner:sfd_discussions/index.html
cohortmanual = course_author:course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually
cohortautomatic = course_author:course_features/cohorts/cohorts_overview.html#all-automated-assignment
# below are the language directory names for the different 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
############## 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 ######################
......
......@@ -14,6 +14,8 @@ import os
from path import Path as path
from tempfile import mkdtemp
from openedx.core.release import RELEASE_LINE
CONFIG_ROOT = path(__file__).abspath().dirname()
TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root"
......@@ -223,7 +225,12 @@ BADGING_BACKEND = 'lms.djangoapps.badges.backends.tests.dummy_backend.DummyBacke
ECOMMERCE_API_URL = 'http://localhost:8043/api/v2/'
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.
from django.db.utils import ProgrammingError
......
......@@ -547,7 +547,7 @@ TEMPLATES = [
'edxmako.shortcuts.footer_context_processor',
# Online contextual help
'context_processors.doc_url',
'help_tokens.context_processor',
'openedx.core.djangoapps.site_configuration.context_processors.configuration_context'
],
# Change 'debug' in your environment settings files - not here.
......@@ -3110,7 +3110,11 @@ REDIRECT_CACHE_KEY_PREFIX = 'redirects'
############## 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 ######################
# The Open edX Enterprise service is currently hosted via the LMS container/process.
......
......@@ -2,6 +2,8 @@
Module for code that should run during LMS startup
"""
import logging
import django
from django.conf import settings
......@@ -10,7 +12,7 @@ from django.conf import settings
settings.INSTALLED_APPS # pylint: disable=pointless-statement
from openedx.core.lib.django_startup import autostartup
import logging
from openedx.core.release import doc_version
import analytics
from openedx.core.djangoapps.monkey_patch import django_db_models_options
......@@ -79,6 +81,10 @@ 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)
......
......@@ -12,10 +12,10 @@
<div class="setup-value">
<% 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.") %>
<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 { %>
<%- 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>
......@@ -6,7 +6,6 @@
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from context_processors import doc_url
from lms.djangoapps.ccx.overrides import get_current_ccx
from openedx.core.djangolib.markup import HTML, Text
......
......@@ -101,6 +101,9 @@ urlpatterns = (
# URLs for managing dark launches of languages
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
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
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/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
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