Пример #1
0
    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()))
Пример #2
0
    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()))
Пример #3
0
    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/index.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()))
Пример #4
0
    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()))
Пример #5
0
def run():
    """
    Executed during django startup
    """
    django_db_models_options.patch()

    # Comprehensive theming needs to be set up before django startup,
    # because modifying django template paths after startup has no effect.
    if is_comprehensive_theming_enabled():
        enable_theming()

    django.setup()

    autostartup()

    add_mimetypes()

    # In order to allow descriptors to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #6
0
        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"),
            )
Пример #7
0
def run():
    """
    Executed during django startup

    NOTE: DO **NOT** add additional code to this method or this file! The Platform Team
          is moving all startup code to more standard locations using Django best practices.
    """
    django_db_models_options.patch()

    # Comprehensive theming needs to be set up before django startup,
    # because modifying django template paths after startup has no effect.
    if is_comprehensive_theming_enabled():
        enable_theming()

    django.setup()

    autostartup()

    add_mimetypes()

    # In order to allow descriptors to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #8
0
        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),
            )
Пример #9
0
def run():
    """
    Executed during django startup
    """
    django_db_models_options.patch()

    # To override the settings before executing the autostartup() for python-social-auth
    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Comprehensive theming needs to be set up before django startup,
    # because modifying django template paths after startup has no effect.
    if is_comprehensive_theming_enabled():
        enable_theming()

    # We currently use 2 template rendering engines, mako and django_templates,
    # and one of them (django templates), requires the directories be added
    # before the django.setup().
    microsite.enable_microsites_pre_startup(log)

    django.setup()

    autostartup()

    add_mimetypes()

    # Mako requires the directories to be added after the django setup.
    microsite.enable_microsites(log)

    # Initialize Segment analytics module by setting the write_key.
    if settings.LMS_SEGMENT_KEY:
        analytics.write_key = settings.LMS_SEGMENT_KEY

    # register any dependency injections that we need to support in edx_proctoring
    # right now edx_proctoring is dependent on the openedx.core.djangoapps.credit
    if settings.FEATURES.get('ENABLE_SPECIAL_EXAMS'):
        # Import these here to avoid circular dependencies of the form:
        # edx-platform app --> DRF --> django translation --> edx-platform app
        from edx_proctoring.runtime import set_runtime_service
        from lms.djangoapps.instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        set_runtime_service('credit', CreditService())

        # register InstructorService (for deleting student attempts and user staff access roles)
        set_runtime_service('instructor', InstructorService())

    # In order to allow modules to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #10
0
def url_for_help(book_slug, path_component):
    """
    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 = 'https://edx.readthedocs.io/projects/{}/en/{}{}'.format(books[book_slug], doc_version(), path_component)
    return url
Пример #11
0
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
Пример #12
0
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,
    )
Пример #13
0
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,
    )
Пример #14
0
 def test_instructor_dashboard_help(self):
     """
     Scenario: Help button opens staff help
     Given that I am viewing the Instructor Dashboard
     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())
     self.instructor_dashboard_page.click_help()
     assert_opened_help_link_is_correct(self, href)
Пример #15
0
 def test_instructor_dashboard_help(self):
     """
     Scenario: Help button opens staff help
     Given that I am viewing the Instructor Dashboard
     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())
     self.instructor_dashboard_page.click_help()
     assert_opened_help_link_is_correct(self, href)
Пример #16
0
def run():
    """
    Executed during django startup

    NOTE: DO **NOT** add additional code to this method or this file! The Platform Team
          is moving all startup code to more standard locations using Django best practices.
    """
    django_db_models_options.patch()

    # We currently use 2 template rendering engines, mako and django_templates,
    # and one of them (django templates), requires the directories be added
    # before the django.setup().
    microsite.enable_microsites_pre_startup(log)

    django.setup()

    autostartup()

    add_mimetypes()

    # Mako requires the directories to be added after the django setup.
    microsite.enable_microsites(log)

    # register any dependency injections that we need to support in edx_proctoring
    # right now edx_proctoring is dependent on the openedx.core.djangoapps.credit and
    # lms.djangoapps.grades
    if settings.FEATURES.get('ENABLE_SPECIAL_EXAMS'):
        # Import these here to avoid circular dependencies of the form:
        # edx-platform app --> DRF --> django translation --> edx-platform app
        from edx_proctoring.runtime import set_runtime_service
        from lms.djangoapps.instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        from lms.djangoapps.grades.services import GradesService
        set_runtime_service('credit', CreditService())

        # register InstructorService (for deleting student attempts and user staff access roles)
        set_runtime_service('instructor', InstructorService())

        set_runtime_service('grades', GradesService())

    # In order to allow modules to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #17
0
    def test_manual_cohort_help(self):
        """
        Scenario: Help in 'What does it mean?' is correct when we create cohort manually.
        Given that I am at 'Cohort' tab of LMS instructor dashboard
        And I check 'Enable Cohorts'
        And I add cohort name it, choose Manual for Cohort Assignment Method and
        No content group for Associated Content Group and save the cohort
        Then you see the UI text "Learners are added to this cohort only when..."
        followed by "What does this mean" link.
        And I click "What does this mean" link then help link should end with
        course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually
        """
        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())

        self.verify_help_link(href)
Пример #18
0
    def test_manual_cohort_help(self):
        """
        Scenario: Help in 'What does it mean?' is correct when we create cohort manually.
        Given that I am at 'Cohort' tab of LMS instructor dashboard
        And I check 'Enable Cohorts'
        And I add cohort name it, choose Manual for Cohort Assignment Method and
        No content group for Associated Content Group and save the cohort
        Then you see the UI text "Learners are added to this cohort only when..."
        followed by "What does this mean" link.
        And I click "What does this mean" link then help link should end with
        course_features/cohorts/cohort_config.html#assign-learners-to-cohorts-manually
        """
        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())

        self.verify_help_link(href)
Пример #19
0
def run():
    """
    Executed during django startup
    """
    django_db_models_options.patch()

    # Comprehensive theming needs to be set up before django startup,
    # because modifying django template paths after startup has no effect.
    if is_comprehensive_theming_enabled():
        enable_theming()

    django.setup()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('ENABLE_NOTIFICATIONS', False):
        startup_notification_subsystem()

    if settings.FEATURES.get('EDX_SOLUTIONS_API', False) and \
            settings.FEATURES.get('DISABLE_SOLUTIONS_APPS_SIGNALS', False):
        disable_solutions_apps_signals()

    # In order to allow descriptors to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #20
0
def run():
    """
    Executed during django startup
    """
    django_db_models_options.patch()

    # To override the settings before executing the autostartup() for python-social-auth
    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Comprehensive theming needs to be set up before django startup,
    # because modifying django template paths after startup has no effect.
    if is_comprehensive_theming_enabled():
        enable_theming()

    # We currently use 2 template rendering engines, mako and django_templates,
    # and one of them (django templates), requires the directories be added
    # before the django.setup().
    microsite.enable_microsites_pre_startup(log)

    django.setup()

    autostartup()

    add_mimetypes()

    # Mako requires the directories to be added after the django setup.
    microsite.enable_microsites(log)

    # Initialize Segment analytics module by setting the write_key.
    if settings.LMS_SEGMENT_KEY:
        analytics.write_key = settings.LMS_SEGMENT_KEY

    # register any dependency injections that we need to support in edx_proctoring
    # right now edx_proctoring is dependent on the openedx.core.djangoapps.credit
    if settings.FEATURES.get('ENABLE_SPECIAL_EXAMS'):
        # Import these here to avoid circular dependencies of the form:
        # edx-platform app --> DRF --> django translation --> edx-platform app
        from edx_proctoring.runtime import set_runtime_service
        from lms.djangoapps.instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        set_runtime_service('credit', CreditService())

        # register InstructorService (for deleting student attempts and user staff access roles)
        set_runtime_service('instructor', InstructorService())

    if settings.FEATURES.get('ENABLE_NOTIFICATIONS', False):
        startup_notification_subsystem()

    if settings.FEATURES.get('EDX_SOLUTIONS_API', False) and \
            settings.FEATURES.get('DISABLE_SOLUTIONS_APPS_SIGNALS', False):
        disable_solutions_apps_signals()

    # In order to allow modules to use a handler url, we need to
    # monkey-patch the x_module library.
    # TODO: Remove this code when Runtimes are no longer created by modulestores
    # https://openedx.atlassian.net/wiki/display/PLAT/Convert+from+Storage-centric+runtimes+to+Application-centric+runtimes
    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)
Пример #21
0
OAUTH_OIDC_ISSUER = 'https://www.example.com/oauth2'

# 5 minute expiration time for JWT id tokens issued for external API requests.
OAUTH_ID_TOKEN_EXPIRATION = 5 * 60

# Partner support link for CMS footer
PARTNER_SUPPORT_EMAIL = ''

# Affiliate cookie tracking
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
# Although Studio does not exable OAuth2 Provider capability, the new approach
# to generating test databases will discover and try to create all tables
# and this setting needs to be present
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'

# Used with Email sending
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS = 5
RETRY_ACTIVATION_EMAIL_TIMEOUT = 0.5

############## DJANGO-USER-TASKS ##############
Пример #22
0
OAUTH_OIDC_ISSUER = 'https://www.example.com/oauth2'

# 5 minute expiration time for JWT id tokens issued for external API requests.
OAUTH_ID_TOKEN_EXPIRATION = 5 * 60

# Partner support link for CMS footer
PARTNER_SUPPORT_EMAIL = ''

# Affiliate cookie tracking
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
# Although Studio does not exable OAuth2 Provider capability, the new approach
# to generating test databases will discover and try to create all tables
# and this setting needs to be present
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'

# Used with Email sending
RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS = 5
RETRY_ACTIVATION_EMAIL_TIMEOUT = 0.5

############## DJANGO-USER-TASKS ##############