diff --git a/common/djangoapps/student/tests/test_microsite.py b/common/djangoapps/student/tests/test_microsite.py
index d89d39900f..f68ab79654 100644
--- a/common/djangoapps/student/tests/test_microsite.py
+++ b/common/djangoapps/student/tests/test_microsite.py
@@ -12,6 +12,8 @@ FAKE_MICROSITE = {
"SITE_NAME": "openedx.localhost",
"university": "fakeuniversity",
"course_org_filter": "fakeorg",
+ "platform_name": "Fake University",
+ "email_from_address": "no-reply@fakeuniversity.com",
"REGISTRATION_EXTRA_FIELDS": {
"address1": "required",
"city": "required",
diff --git a/common/djangoapps/student/tests/test_reset_password.py b/common/djangoapps/student/tests/test_reset_password.py
index d4cfca5d19..511395fbe3 100644
--- a/common/djangoapps/student/tests/test_reset_password.py
+++ b/common/djangoapps/student/tests/test_reset_password.py
@@ -12,6 +12,7 @@ from django.test.client import RequestFactory
from django.contrib.auth.models import User
from django.contrib.auth.hashers import UNUSABLE_PASSWORD
from django.contrib.auth.tokens import default_token_generator
+
from django.utils.http import int_to_base36
from mock import Mock, patch
@@ -22,7 +23,7 @@ from student.tests.factories import UserFactory
from student.tests.test_email import mock_render_to_string
from util.testing import EventTestMixin
-from test_microsite import fake_site_name
+from .test_microsite import fake_microsite_get_value
@ddt.ddt
@@ -185,7 +186,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
- @patch("microsite_configuration.microsite.get_value", fake_site_name)
+ @patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
@patch('django.core.mail.send_mail')
def test_reset_password_email_microsite(self, send_email):
"""
@@ -198,7 +199,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
req.get_host = Mock(return_value=None)
req.user = self.user
password_reset(req)
- _, msg, _, _ = send_email.call_args[0]
+ _, msg, from_addr, _ = send_email.call_args[0]
reset_msg = "you requested a password reset for your user account at openedx.localhost"
@@ -207,6 +208,7 @@ class ResetPasswordTests(EventTestMixin, TestCase):
self.assert_event_emitted(
SETTING_CHANGE_INITIATED, user_id=self.user.id, setting=u'password', old=None, new=None
)
+ self.assertEqual(from_addr, "no-reply@fakeuniversity.com")
@patch('student.views.password_reset_confirm')
def test_reset_password_bad_token(self, reset_confirm):
@@ -232,6 +234,16 @@ class ResetPasswordTests(EventTestMixin, TestCase):
self.user = User.objects.get(pk=self.user.pk)
self.assertTrue(self.user.is_active)
+ @patch('student.views.password_reset_confirm')
+ @patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
+ def test_reset_password_good_token_microsite(self, reset_confirm):
+ """Tests password reset confirmation page for micro site"""
+
+ good_reset_req = self.request_factory.get('/password_reset_confirm/{0}-{1}/'.format(self.uidb36, self.token))
+ password_reset_confirm_wrapper(good_reset_req, self.uidb36, self.token)
+ confirm_kwargs = reset_confirm.call_args[1]
+ self.assertEquals(confirm_kwargs['extra_context']['platform_name'], 'Fake University')
+
@patch('student.views.password_reset_confirm')
def test_reset_password_with_reused_password(self, reset_confirm):
"""Tests good token and uidb36 in password reset"""
diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py
index f685c46d4e..624a945f96 100644
--- a/common/djangoapps/student/views.py
+++ b/common/djangoapps/student/views.py
@@ -1036,6 +1036,7 @@ def login_user(request, error=""): # pylint: disable=too-many-statements,unused
third_party_auth_successful = False
trumped_by_first_party_auth = bool(request.POST.get('email')) or bool(request.POST.get('password'))
user = None
+ platform_name = microsite.get_value("platform_name", settings.PLATFORM_NAME)
if third_party_auth_requested and not trumped_by_first_party_auth:
# The user has already authenticated via third-party auth and has not
@@ -1057,17 +1058,17 @@ def login_user(request, error=""): # pylint: disable=too-many-statements,unused
username=username, backend_name=backend_name))
return HttpResponse(
_("You've successfully logged into your {provider_name} account, but this account isn't linked with an {platform_name} account yet.").format(
- platform_name=settings.PLATFORM_NAME, provider_name=requested_provider.name
+ platform_name=platform_name, provider_name=requested_provider.name
)
+ "
" +
_("Use your {platform_name} username and password to log into {platform_name} below, "
"and then link your {platform_name} account with {provider_name} from your dashboard.").format(
- platform_name=settings.PLATFORM_NAME, provider_name=requested_provider.name
+ platform_name=platform_name, provider_name=requested_provider.name
)
+ "
" +
_("If you don't have an {platform_name} account yet, "
"click Register at the top of the page.").format(
- platform_name=settings.PLATFORM_NAME),
+ platform_name=platform_name),
content_type="text/plain",
status=403
)
@@ -1907,7 +1908,7 @@ def password_reset(request):
form = PasswordResetFormNoActive(request.POST)
if form.is_valid():
form.save(use_https=request.is_secure(),
- from_email=settings.DEFAULT_FROM_EMAIL,
+ from_email=microsite.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL),
request=request,
domain_override=request.get_host())
# When password change is complete, a "edx.user.settings.changed" event will be emitted.
@@ -1993,12 +1994,12 @@ def password_reset_confirm_wrapper(
'form': None,
'title': _('Password reset unsuccessful'),
'err_msg': err_msg,
- 'platform_name': settings.PLATFORM_NAME,
+ 'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
}
return TemplateResponse(request, 'registration/password_reset_confirm.html', context)
else:
# we also want to pass settings.PLATFORM_NAME in as extra_context
- extra_context = {"platform_name": settings.PLATFORM_NAME}
+ extra_context = {"platform_name": microsite.get_value('platform_name', settings.PLATFORM_NAME)}
if request.method == 'POST':
# remember what the old password hash is before we call down