Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')),
Expand Down
7 changes: 6 additions & 1 deletion openedx/core/djangoapps/dark_lang/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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()
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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):
"""
Expand Down
Loading