Commit 06c98269 by George Song Committed by GitHub

Merge pull request #14845 from Salomari1987/salah/password_reset_email_subject

Use platform_name instead of site_name in password reset email
parents 2ffabe63 8dba6c49
......@@ -281,4 +281,5 @@ Brian Mesick <bmesick@edx.org>
Jeff LaJoie <jlajoie@edx.org>
Ivan Ivić <iivic@edx.org>
Brandon Baker <bcbaker@wesleyan.edu>
Salah Alomari <salomari@qrf.org>
Shirley He <she@edx.org>
......@@ -62,7 +62,7 @@ class PasswordResetFormNoActive(PasswordResetForm):
def save(
self,
domain_override=None,
subject_template_name='registration/password_reset_subject.txt',
subject_template_name='emails/password_reset_subject.txt',
email_template_name='registration/password_reset_email.html',
use_https=False,
token_generator=default_token_generator,
......
......@@ -185,18 +185,22 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
req = self.request_factory.post(
'/password_reset/', {'email': self.user.email}
)
req.is_secure = Mock(return_value=True)
req.get_host = Mock(return_value=domain_override)
req.user = self.user
password_reset(req)
_, msg, _, _ = send_email.call_args[0]
reset_msg = "you requested a password reset for your user account at {}"
reset_intro_msg = "you requested a password reset for your user account at {}".format(platform_name)
self.assertIn(reset_intro_msg, msg)
reset_link = "https://{}/"
if domain_override:
reset_msg = reset_msg.format(domain_override)
reset_link = reset_link.format(domain_override)
else:
reset_msg = reset_msg.format(settings.SITE_NAME)
reset_link = reset_link.format(settings.SITE_NAME)
self.assertIn(reset_msg, msg)
self.assertIn(reset_link, msg)
sign_off = "The {} Team".format(platform_name)
self.assertIn(sign_off, msg)
......@@ -221,7 +225,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
password_reset(req)
_, msg, from_addr, _ = send_email.call_args[0]
reset_msg = "you requested a password reset for your user account at openedx.localhost"
reset_msg = "you requested a password reset for your user account at {}".format(fake_get_value('platform_name'))
self.assertIn(reset_msg, msg)
......@@ -297,3 +301,21 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
self.assertEquals(confirm_kwargs['extra_context']['platform_name'], 'Fake University')
self.user = User.objects.get(pk=self.user.pk)
self.assertTrue(self.user.is_active)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
@patch('django.core.mail.send_mail')
@ddt.data('Crazy Awesome Site', 'edX')
def test_reset_password_email_subject(self, platform_name, send_email):
"""
Tests that the right platform name is included in
the reset password email subject
"""
with patch("django.conf.settings.PLATFORM_NAME", platform_name):
req = self.request_factory.post(
'/password_reset/', {'email': self.user.email}
)
req.user = self.user
password_reset(req)
subj, _, _, _ = send_email.call_args[0]
self.assertIn(platform_name, subj)
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Password reset on {{ platform_name }}{% endblocktrans %}
{% endautoescape %}
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ platform_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
......
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