diff --git a/cms/urls.py b/cms/urls.py index de35a09483ce..a1b8f1eb7e18 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -7,6 +7,7 @@ from django.conf.urls.static import static from django.contrib import admin from django.contrib.admin import autodiscover as django_autodiscover +from django.shortcuts import redirect from django.urls import include, path, re_path from django.utils.translation import gettext_lazy as _ from django.views.generic import RedirectView @@ -86,7 +87,7 @@ ), # Darklang View to change the preview language (or dark language) - path('update_lang/', include('openedx.core.djangoapps.dark_lang.urls', namespace='dark_lang')), + path('update_lang/', lambda request: redirect(f'{settings.LMS_ROOT_URL}/update_lang/')), # For redirecting to help pages. path('help_token/', include('help_tokens.urls')), diff --git a/openedx/core/djangoapps/dark_lang/tests.py b/openedx/core/djangoapps/dark_lang/tests.py index 76433cc28a7e..53f9eaf63e15 100644 --- a/openedx/core/djangoapps/dark_lang/tests.py +++ b/openedx/core/djangoapps/dark_lang/tests.py @@ -18,7 +18,7 @@ with_site_configuration, with_site_configuration_context, ) -from openedx.core.djangolib.testing.utils import CacheIsolationTestCase +from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms UNSET = object() @@ -259,6 +259,7 @@ def _post_clear_preview_lang(self): """ return self.client.post('/update_lang/', {'action': 'reset_preview_language'}) + @skip_unless_lms def test_preview_lang_with_released_language(self): # Preview lang should always override selection self._post_set_preview_lang('rel') @@ -272,6 +273,7 @@ def test_preview_lang_with_released_language(self): self.client.get('/home') self.assert_cookie_lang_equals('rel') + @skip_unless_lms def test_preview_lang_with_dark_language(self): self._post_set_preview_lang('unrel') self.client.get('/home') @@ -290,6 +292,7 @@ def test_empty_preview_language(self): self.client.get('/home') self.assert_cookie_lang_equals('rel') + @skip_unless_lms def test_clear_lang(self): # Clear a language when no language was set self._post_clear_preview_lang() @@ -335,6 +338,7 @@ def test_accept_chinese_language_codes(self): self.process_middleware_request(accept='zh-Hans;q=1.0, zh-Hant-TW;q=0.5, zh-HK;q=0.3') ) + @skip_unless_lms def test_language_cookie_is_set(self): site_lang = settings.LANGUAGE_CODE url = '/dashboard' @@ -370,6 +374,7 @@ def test_language_cookie_is_set(self): assert response.cookies.get(settings.LANGUAGE_COOKIE_NAME).value == '' assert response['Content-Language'] == site_lang + @skip_unless_lms @with_site_configuration(configuration={'LANGUAGE_CODE': 'es'}) def test_preview_language_ignores_site_configuration(self): """