Commit fe2e4a74 by Ned Batchelder

Merge pull request #11273 from openfun/fun/fix_default_email_localization

Fix (un)enrollment email default language
parents 31841bdc 5fee7480
......@@ -427,6 +427,7 @@ def render_message_to_string(subject_template, message_template, param_dict, lan
Returns two strings that correspond to the rendered, translated email
subject and message.
"""
language = language or settings.LANGUAGE_CODE
with override_language(language):
return get_subject_and_message(subject_template, message_template, param_dict)
......
......@@ -5,13 +5,14 @@ Unit tests for the localization of emails sent by instructor.api methods.
from django.core import mail
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from nose.plugins.attrib import attr
from courseware.tests.factories import InstructorFactory
from lang_pref import LANGUAGE_KEY
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference, delete_user_preference
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
......@@ -89,3 +90,10 @@ class TestInstructorAPIEnrollmentEmailLocalization(SharedModuleStoreTestCase):
# Student is unknown, so the platform language should be used
self.update_enrollement("enroll", "newuser@hotmail.com")
self.check_outbox("You have been")
@override_settings(LANGUAGE_CODE="fr")
def test_user_without_preference_receives_email_in_french(self):
delete_user_preference(self.student, LANGUAGE_KEY)
self.update_enrollement("enroll", self.student.email)
self.check_outbox_is_french()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment