From b6830d0f702345c2531ab5de0cc51a6afe3cc85d Mon Sep 17 00:00:00 2001 From: muhammad-ammar Date: Thu, 25 Apr 2024 12:48:23 +0500 Subject: [PATCH] fix: update langugae cookie with enterprise default language --- CHANGELOG.rst | 4 ++++ enterprise/__init__.py | 2 +- enterprise/middleware.py | 5 ++++- enterprise/settings/test.py | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0c327c738e..b75b1ab03a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,10 @@ Change Log Unreleased ---------- +[4.16.5] +-------- +* fix: update langugae cookie with enterprise default language + [4.16.4] -------- * revert: fix: set default langauge for all learners linked with an enteprise customer diff --git a/enterprise/__init__.py b/enterprise/__init__.py index 0ccfbd5bf6..14366bd1a1 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "4.16.4" +__version__ = "4.16.5" diff --git a/enterprise/middleware.py b/enterprise/middleware.py index 4d4fcbb17f..8cec8cd744 100644 --- a/enterprise/middleware.py +++ b/enterprise/middleware.py @@ -2,6 +2,7 @@ Middleware for enterprise app. """ +from django.conf import settings from django.utils.deprecation import MiddlewareMixin from enterprise.utils import get_enterprise_customer_for_user @@ -70,4 +71,6 @@ def process_request(self, request): # then set the default language as the learner's language if not user_pref and not is_request_from_mobile_app(request): # pylint: disable=protected-access - request._anonymous_user_cookie_lang = enterprise_customer.default_language + default_language = enterprise_customer.default_language + request._anonymous_user_cookie_lang = default_language + request.COOKIES[settings.LANGUAGE_COOKIE_NAME] = default_language diff --git a/enterprise/settings/test.py b/enterprise/settings/test.py index f6dae73273..c2c9032b14 100644 --- a/enterprise/settings/test.py +++ b/enterprise/settings/test.py @@ -329,7 +329,8 @@ def root(*args): 'SAP': 1, } -LANGUAGE_COOKIE = 'openedx-language-preference' +LANGUAGE_COOKIE_NAME = "openedx-language-preference" +SHARED_COOKIE_DOMAIN = '' ENTERPRISE_BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL = f'{LMS_INTERNAL_ROOT_URL}/oauth2' ENTERPRISE_BACKEND_SERVICE_EDX_OAUTH2_KEY = 'test_backend_oauth2_key'