From 3dd8acc0d5bd804a02433738ddc059a988ab7175 Mon Sep 17 00:00:00 2001 From: "Kyle D. McCormick" Date: Tue, 18 Feb 2025 15:50:44 -0500 Subject: [PATCH] feat: Only display Preview Language Setting (dark_lang) in LMS Previously, there were two (identical) ways to preview dark language: 1. /update_lang 2. /update_lang Now, (1) will simply redirect to (2). So, the Preview Language Setting page will only render in an LMS context. This has no impact on end-user functionality. It has only a very minor UX end-user impact. The purpose of this is to allow us to completely retire the legacy Studio frontend without losing any end-user functionality. This page is not yet available in an MFE, which will need to be the eventual solution. --- cms/urls.py | 3 ++- openedx/core/djangoapps/dark_lang/tests.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cms/urls.py b/cms/urls.py index 048339bc9fe9..ac73a808fa4f 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -9,6 +9,7 @@ from django.urls import path, re_path from django.utils.translation import gettext_lazy as _ from django.contrib import admin +from django.shortcuts import redirect from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView from auth_backends.urls import oauth2_urlpatterns from edx_api_doc_tools import make_docs_urls @@ -87,7 +88,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 765d2ea3091f..eec458925f0b 100644 --- a/openedx/core/djangoapps/dark_lang/tests.py +++ b/openedx/core/djangoapps/dark_lang/tests.py @@ -251,6 +251,9 @@ def _post_set_preview_lang(self, preview_language): """ Sends a post request to set the preview language """ + # @@TODO make this call set_user_preference, + # and then have a small separate LMS-only test class just to call the + # POST and ensure it sets the user preference. return self.client.post('/update_lang/', {'preview_language': preview_language, 'action': 'set_preview_language'}) # lint-amnesty, pylint: disable=line-too-long def _post_clear_preview_lang(self):