From 2338ac4babb9820270d84755f2fabe34ab966aa1 Mon Sep 17 00:00:00 2001 From: Luis Felipe Castano Date: Mon, 10 Jul 2023 14:22:21 -0500 Subject: [PATCH] Revert "feat(LC-v2): select language" This reverts commit 303f68f65dc9c8c8fdb89e30b21fec09fe6e1dd8. --- openedx/core/djangoapps/dark_lang/middleware.py | 13 ++----------- openedx/core/djangoapps/dark_lang/models.py | 13 +++---------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/openedx/core/djangoapps/dark_lang/middleware.py b/openedx/core/djangoapps/dark_lang/middleware.py index efaa62cc4d6..36c4798a798 100644 --- a/openedx/core/djangoapps/dark_lang/middleware.py +++ b/openedx/core/djangoapps/dark_lang/middleware.py @@ -86,10 +86,9 @@ def beta_langs(self): def process_request(self, request): """ - eduNEXT: this middleware will always process the requests. - The model has been modified to not even attempt the db lookup + Prevent user from requesting un-released languages except by using the preview-lang query string. """ - if not settings.FEATURES.get("EDNX_SITE_AWARE_LOCALE", False) and not DarkLangConfig.current().enabled: + if not DarkLangConfig.current().enabled: return self._clean_accept_headers(request) @@ -138,13 +137,8 @@ def _clean_accept_headers(self, request): Remove any language that is not either in ``self.released_langs`` or a territory of one of those languages. """ - ednx_locale = settings.FEATURES.get("EDNX_SITE_AWARE_LOCALE", False) accept = request.META.get('HTTP_ACCEPT_LANGUAGE', None) if accept is None or accept == '*': - if ednx_locale: - # eduNEXT: return the site aware settings.LANGUAGE_CODE - # so that django.utils.locale.LocaleMiddleware can pick it up - request.META['HTTP_ACCEPT_LANGUAGE'] = f"{settings.LANGUAGE_CODE};q=0.1" return new_accept = [] @@ -153,9 +147,6 @@ def _clean_accept_headers(self, request): if fuzzy_code: # Formats lang and priority into a valid accept header fragment. new_accept.append(f"{fuzzy_code};q={priority}") - elif ednx_locale: - # eduNEXT: if there is no match, we set it to the settings.LANGUAGE_CODE - new_accept.append(f"{settings.LANGUAGE_CODE};q=0.1") new_accept = ", ".join(new_accept) diff --git a/openedx/core/djangoapps/dark_lang/models.py b/openedx/core/djangoapps/dark_lang/models.py index ef842910037..1da7670cb32 100644 --- a/openedx/core/djangoapps/dark_lang/models.py +++ b/openedx/core/djangoapps/dark_lang/models.py @@ -4,7 +4,6 @@ from config_models.models import ConfigurationModel -from django.conf import settings from django.db import models @@ -36,19 +35,13 @@ def released_languages_list(self): ``released_languages`` as a list of language codes. Example: ['it', 'de-at', 'es', 'pt-br'] - - eduNEXT: we support only the list of available languages from the site - otherwise is the same as having no configuration """ - released_languages = self.released_languages - - if settings.FEATURES.get("EDNX_SITE_AWARE_LOCALE", False): - released_languages = getattr(settings, "released_languages", "") + if not self.released_languages.strip(): + return [] - languages = [lang.lower().strip() for lang in released_languages.split(',')] + languages = [lang.lower().strip() for lang in self.released_languages.split(',')] # Put in alphabetical order languages.sort() - return languages @property