diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 3cb5c21f2c..798f232102 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -426,9 +426,15 @@ class UserProfile(models.Model): meta = models.TextField(blank=True) # JSON dictionary for future expansion courseware = models.CharField(blank=True, max_length=255, default='course.xml') + # Language is deprecated and no longer used. Old rows exist that have + # user-entered free form text values (ex. "English"), some of which have + # non-ASCII values. You probably want UserPreference version of this, which + # stores the user's preferred language code. See openedx/core/djangoapps/lang_pref + # for more information. + language = models.CharField(blank=True, max_length=255, db_index=True) + # Location is no longer used, but is held here for backwards compatibility # for users imported from our first class. - language = models.CharField(blank=True, max_length=255, db_index=True) location = models.CharField(blank=True, max_length=255, db_index=True) # Optional demographic data we started capturing from Fall 2012 diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index b743c377f9..68eb9e2632 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -10,6 +10,7 @@ from functools import wraps import pytz from consent.models import DataSharingConsent +from django.conf import settings from django.contrib.auth import authenticate, get_user_model, logout from django.contrib.sites.models import Site from django.core.cache import cache @@ -39,6 +40,7 @@ from openedx.core.djangoapps.ace_common.template_context import get_base_templat from openedx.core.djangoapps.api_admin.models import ApiAccessRequest from openedx.core.djangoapps.credit.models import CreditRequirementStatus, CreditRequest from openedx.core.djangoapps.course_groups.models import UnregisteredLearnerCohortAssignments +from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.profile_images.images import remove_profile_images from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_names, set_has_profile_image from openedx.core.djangolib.oauth2_retirement_utils import retire_dot_oauth2_models, retire_dop_oauth2_models @@ -404,9 +406,14 @@ class DeactivateLogoutView(APIView): site = Site.objects.get_current() notification_context = get_base_template_context(site) notification_context.update({'full_name': request.user.profile.name}) + language_code = request.user.preferences.model.get_value( + request.user, + LANGUAGE_KEY, + default=settings.LANGUAGE_CODE + ) notification = DeletionNotificationMessage().personalize( recipient=Recipient(username='', email_address=user_email), - language=request.user.profile.language, + language=language_code, user_context=notification_context, ) ace.send(notification)