コード例 #1
0
ファイル: startup.py プロジェクト: DevCode1/edx-platform
def run():
    """
    Executed during django startup
    """

    # Patch the xml libs.
    from safe_lxml import defuse_xml_libs
    defuse_xml_libs()

    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and 
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)
コード例 #2
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_stanford_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)

    # register any dependency injections that we need to support in edx_proctoring
    # right now edx_proctoring is dependent on the openedx.core.djangoapps.credit
    # as well as the instructor dashboard (for deleting student attempts)
    if settings.FEATURES.get('ENABLE_PROCTORED_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 instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        set_runtime_service('credit', CreditService())
        set_runtime_service('instructor', InstructorService())
コード例 #3
0
ファイル: startup.py プロジェクト: adoosii/edx-platform
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_stanford_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # 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
    # as well as the instructor dashboard (for deleting student attempts)
    if settings.FEATURES.get('ENABLE_PROCTORED_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 instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        set_runtime_service('credit', CreditService())
        set_runtime_service('instructor', InstructorService())
コード例 #4
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(
            settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)

    # register any dependency injections that we need to support in edx_proctoring
    # right now edx_proctoring is dependent on the openedx.core.djangoapps.credit
    # as well as the instructor dashboard (for deleting student attempts)
    if settings.FEATURES.get('ENABLE_PROCTORED_EXAMS'):
        set_runtime_service('credit', CreditService())
        set_runtime_service('instructor', InstructorService())
コード例 #5
0
ファイル: startup.py プロジェクト: Taxellool/edx-platform
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)

    # Monkey patch the keyword function map
    if keyword_substitution.keyword_function_map_is_empty():
        keyword_substitution.add_keyword_function_map(get_keyword_function_map())
        # Once keyword function map is set, make update function do nothing
        keyword_substitution.add_keyword_function_map = lambda x: None
コード例 #6
0
def run():
    """
    Executed during django startup
    """

    # Patch the xml libs.
    from safe_lxml import defuse_xml_libs
    defuse_xml_libs()

    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(
            settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)
コード例 #7
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # Initialize Segment.io analytics module. Flushes first time a message is received and
    # every 50 messages thereafter, or if 10 seconds have passed since last flush
    if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(
            settings, 'SEGMENT_IO_LMS_KEY'):
        analytics.init(settings.SEGMENT_IO_LMS_KEY, flush_at=50)

    # Monkey patch the keyword function map
    if keyword_substitution.keyword_function_map_is_empty():
        keyword_substitution.add_keyword_function_map(
            get_keyword_function_map())
        # Once keyword function map is set, make update function do nothing
        keyword_substitution.add_keyword_function_map = lambda x: None
コード例 #8
0
ファイル: startup.py プロジェクト: truonglx1/lms
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_stanford_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # 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
    # as well as the instructor dashboard (for deleting student attempts)
    if settings.FEATURES.get('ENABLE_PROCTORED_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 instructor.services import InstructorService
        from openedx.core.djangoapps.credit.services import CreditService
        set_runtime_service('credit', CreditService())
        set_runtime_service('instructor', InstructorService())
コード例 #9
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()
コード例 #10
0
 def test_not_patch(self, attribute_name):
     """
     Test that functions are not patched unintentionally
     """
     self.unpatch_all()
     old_attribute = getattr(_trans, attribute_name)
     patch()
     new_attribute = getattr(_trans, attribute_name)
     self.assertIs(old_attribute, new_attribute)
コード例 #11
0
 def test_not_patch(self, attribute_name):
     """
     Test that functions are not patched unintentionally
     """
     self.unpatch_all()
     old_attribute = getattr(_trans, attribute_name)
     patch()
     new_attribute = getattr(_trans, attribute_name)
     self.assertIs(old_attribute, new_attribute)
コード例 #12
0
    def cleanup(self):
        """
        Revert translation functions to previous state

        Since the end state varies, we always unpatch to remove any
        changes, then repatch again iff the module was already
        patched when the test began.
        """
        self.unpatch_all()
        if self.was_patched:
            patch()
コード例 #13
0
    def cleanup(self):
        """
        Revert translation functions to previous state

        Since the end state varies, we always unpatch to remove any
        changes, then repatch again iff the module was already
        patched when the test began.
        """
        self.unpatch_all()
        if self.was_patched:
            patch()
コード例 #14
0
ファイル: startup.py プロジェクト: akbargumbira/Labster.EdX
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get("USE_CUSTOM_THEME", False):
        enable_theme()
コード例 #15
0
ファイル: startup.py プロジェクト: jswope00/griffinx
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
コード例 #16
0
def run():
    """
    Executed during django startup
    """
    # Patch the xml libs.
    from safe_lxml import defuse_xml_libs
    defuse_xml_libs()

    django_utils_translation.patch()

    autostartup()

    add_mimetypes()
コード例 #17
0
 def test_unpatch(self, attribute):
     """
     Test that unpatch gracefully handles unpatched functions
     """
     patch()
     self.assertTrue(is_patched())
     self.unpatch_all()
     self.assertFalse(is_patched())
     old_attribute = getattr(_trans, attribute)
     self.unpatch_all()
     new_attribute = getattr(_trans, attribute)
     self.assertIs(old_attribute, new_attribute)
     self.assertFalse(is_patched())
コード例 #18
0
 def test_unpatch(self, attribute):
     """
     Test that unpatch gracefully handles unpatched functions
     """
     patch()
     self.assertTrue(is_patched())
     self.unpatch_all()
     self.assertFalse(is_patched())
     old_attribute = getattr(_trans, attribute)
     self.unpatch_all()
     new_attribute = getattr(_trans, attribute)
     self.assertIs(old_attribute, new_attribute)
     self.assertFalse(is_patched())
コード例 #19
0
ファイル: startup.py プロジェクト: kotky/edx-platform
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
    if settings.FEATURES.get('ENABLE_NOTIFICATIONS', False):
        startup_notification_subsystem()
コード例 #20
0
ファイル: startup.py プロジェクト: mrvinceo/edx-platform
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

	if settings.FEATURES.get('USE_CUSTOM_THEME'):
        theme_root = settings.ENV_ROOT / 'themes' / settings.THEME_NAME
        settings.STATICFILES_DIRS.append(
            (u'themes/{}'.format(settings.THEME_NAME), theme_root / 'static')
        )
コード例 #21
0
ファイル: startup.py プロジェクト: miptliot/edx-platform
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        from third_party_auth import settings as auth_settings
        auth_settings.apply_settings(settings)

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
コード例 #22
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        from third_party_auth import settings as auth_settings
        auth_settings.apply_settings(settings)

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
コード例 #23
0
def run():
    """
    Executed during django startup
    """
    # Patch the xml libs.
    from safe_lxml import defuse_xml_libs
    defuse_xml_libs()

    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
コード例 #24
0
 def test_patch_attributes(self, attribute):
     """
     Test that patch changes the attribute
     """
     self.unpatch_all()
     self.assertFalse(is_patched())
     old_attribute = getattr(_trans, attribute)
     patch()
     new_attribute = getattr(_trans, attribute)
     self.assertIsNot(old_attribute, new_attribute)
     self.assertTrue(is_patched())
     old_attribute = getattr(_trans, attribute)
     patch()
     new_attribute = getattr(_trans, attribute)
     self.assertIsNot(old_attribute, new_attribute)
     self.assertTrue(is_patched())
コード例 #25
0
def run():
    """
    Executed during django startup
    """
    # Patch the xml libs.
    from safe_lxml import defuse_xml_libs
    defuse_xml_libs()

    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()
コード例 #26
0
 def test_patch_attributes(self, attribute):
     """
     Test that patch changes the attribute
     """
     self.unpatch_all()
     self.assertFalse(is_patched())
     old_attribute = getattr(_trans, attribute)
     patch()
     new_attribute = getattr(_trans, attribute)
     self.assertIsNot(old_attribute, new_attribute)
     self.assertTrue(is_patched())
     old_attribute = getattr(_trans, attribute)
     patch()
     new_attribute = getattr(_trans, attribute)
     self.assertIsNot(old_attribute, new_attribute)
     self.assertTrue(is_patched())
コード例 #27
0
ファイル: startup.py プロジェクト: iivic/BoiseStateX
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    # 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 = cms.lib.xblock.runtime.local_resource_url
コード例 #28
0
ファイル: startup.py プロジェクト: ahmadiga/min_edx
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_theme()

    # 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 = cms.lib.xblock.runtime.local_resource_url
コード例 #29
0
def run():
    """
    Executed during django startup
    """
    django_utils_translation.patch()

    autostartup()

    add_mimetypes()

    if settings.FEATURES.get('USE_CUSTOM_THEME', False):
        enable_stanford_theme()

    if settings.FEATURES.get('USE_MICROSITES', False):
        enable_microsites()

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH', False):
        enable_third_party_auth()

    # 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 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
コード例 #30
0
 def test_patch(self):
     """
     Test that `self._` correctly translates text before, during, and
     after being monkey-patched.
     """
     self.assert_translations()
     was_successful = patch()
     self.assertTrue(was_successful)
     self.assert_translations()
     was_successful = unpatch()
     self.assertTrue(was_successful)
     self.assert_translations()
コード例 #31
0
 def test_patch(self):
     """
     Test that `self._` correctly translates text before, during, and
     after being monkey-patched.
     """
     self.assert_translations()
     was_successful = patch()
     self.assertTrue(was_successful)
     self.assert_translations()
     was_successful = unpatch()
     self.assertTrue(was_successful)
     self.assert_translations()