diff --git a/cms/djangoapps/contentstore/context_processors.py b/cms/djangoapps/contentstore/context_processors.py
index 076b06bde1..0eff961a83 100644
--- a/cms/djangoapps/contentstore/context_processors.py
+++ b/cms/djangoapps/contentstore/context_processors.py
@@ -1,43 +1,71 @@
import ConfigParser
-from locale import getlocale
from django.conf import settings
+import logging
+
+log = logging.getLogger(__name__)
+
+
+# Open and parse the configuration file when the module is initialized
config_file = open(settings.REPO_ROOT / "docs" / "config.ini")
config = ConfigParser.ConfigParser()
config.readfp(config_file)
def doc_url(request=None):
+ """
+ This function is added in the list of TEMPLATE_CONTEXT_PROCESSORS, 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.
+ """
def get_online_help_info(page_token):
+ """
+ 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.ini file. If it doesn't, the "default"
+ option is used instead.
- def get_config_value(section_name, key, default_key="default"):
+ 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(section_name, option, default_option="default"):
try:
- return config.get(section_name, key)
+ return config.get(section_name, option)
except (ConfigParser.NoOptionError, AttributeError):
- return config.get(section_name, default_key)
+ log.debug("Didn't find a configuration option for '%s' section and '%s' option", section_name, option)
+ return config.get(section_name, default_option)
- def get_page_path(page_token):
- return get_config_value("pages", page_token)
-
- def get_langage_path(request):
- language_code = settings.LANGUAGE_CODE
- return get_config_value("locales", language_code)
-
- def get_url(base_option):
- return "{base_url}/{language}/{version}/{page_path}".format(
- base_url=config.get("server_settings", base_option),
+ def get_doc_url():
+ return "{url_base}/{language}/{version}/{page_path}".format(
+ url_base=config.get("help_settings", "url_base"),
language=language_dir,
- version=config.get("server_settings", "version"),
+ version=config.get("help_settings", "version"),
page_path=page_path,
)
- language_dir = get_langage_path(request)
- page_path = get_page_path(page_token)
+ def get_pdf_url():
+ return "{pdf_base}/{version}/{pdf_file}".format(
+ pdf_base=config.get("pdf_settings", "pdf_base"),
+ version=config.get("help_settings", "version"),
+ pdf_file=config.get("pdf_settings", "pdf_file"),
+ )
+
+ language_dir = get_config_value("locales", settings.LANGUAGE_CODE)
+ page_path = get_config_value("pages", page_token)
return {
- "doc_url": get_url("base_url"),
- "pdf_url": get_url("base_pdf"),
+ "doc_url": get_doc_url(),
+ "pdf_url": get_pdf_url(),
}
return {'get_online_help_info': get_online_help_info}
diff --git a/cms/djangoapps/contentstore/features/course-export.py b/cms/djangoapps/contentstore/features/course-export.py
index e9d2a78c82..bfbb855670 100644
--- a/cms/djangoapps/contentstore/features/course-export.py
+++ b/cms/djangoapps/contentstore/features/course-export.py
@@ -6,11 +6,16 @@ from component_settings_editor_helpers import enter_xml_in_advanced_problem
from nose.tools import assert_true, assert_equal
-@step('I export the course$')
-def i_export_the_course(step):
+@step('I go to the export page$')
+def i_go_to_the_export_page(step):
world.click_tools()
link_css = 'li.nav-course-tools-export a'
world.css_click(link_css)
+
+
+@step('I export the course$')
+def i_export_the_course(step):
+ step.given('I go to the export page')
world.css_click('a.action-export')
@@ -30,7 +35,7 @@ def i_enter_bad_xml(step):
@step('I edit and enter an ampersand$')
-def i_enter_bad_xml(step):
+def i_enter_an_ampersand(step):
enter_xml_in_advanced_problem(step, "
${_("If your textbook doesn't have individual chapters, you can upload the entire text as a single chapter and enter a name of your choice in the Chapter Name field.")}
<% - help_doc_urls = get_online_help_info(online_help_token) + help_doc_urls = get_online_help_info(online_help_token()) %> - + diff --git a/docs/config.ini b/docs/config.ini index 4fb795ada6..634e88e8f1 100644 --- a/docs/config.ini +++ b/docs/config.ini @@ -1,10 +1,18 @@ # below are the server-wide settings for documentation -[server_settings] -base_url = http://edx.readthedocs.org/projects/edx-partner-course-staff -base_pdf = https://media.readthedocs.org/pdf/edx-partner-course-staff +[help_settings] +url_base = http://edx.readthedocs.org/projects/edx-partner-course-staff version = latest + +# 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/cms/djangoapps/contentstore/features/help.feature [pages] default = index.html home = getting_started/get_started.html @@ -21,6 +29,7 @@ checklist = building_course/creating_new_course.html#use-the-course-checklist import = building_course/export_import_course.html export = building_course/export_import_course.html + # below are the language directory names for the different locales [locales] default = en