Revert pull request #22042

Revert "Fix code quality test failures"

This reverts commit 8c55e11d1f.

Revert "Fix celery send_activation_email task failure"

This reverts commit 810eea0e51.

Revert "Convert Account Activation Emails to edx-ACE"

This reverts commit 7984c37a4f.
This commit is contained in:
Ned Batchelder
2019-10-18 15:29:02 -04:00
parent 05ab349c88
commit ea30aba6fc
19 changed files with 228 additions and 250 deletions

View File

@@ -0,0 +1,11 @@
<%! from django.utils.translation import ugettext as _ %>
${_("Thank you for signing up for {studio_name}! To activate your account, please copy and paste this address into your web browser's address bar:").format(studio_name=settings.STUDIO_NAME)}
% if is_secure:
https://${ site }/activate/${ key }
% else:
http://${ site }/activate/${ key }
% endif
${_("If you didn't request this, you don't need to do anything; you won't receive any more email from us. Please do not reply to this e-mail; if you require assistance, check the help section of the {studio_name} web site.").format(studio_name=settings.STUDIO_NAME)}

View File

@@ -0,0 +1,2 @@
<%! from django.utils.translation import ugettext as _ %>
${_("Your account for {studio_name}").format(studio_name=settings.STUDIO_NAME)}

View File

@@ -381,9 +381,7 @@ def generate_activation_email_context(user, registration):
'key': registration.activation_key, 'key': registration.activation_key,
'lms_url': configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL), 'lms_url': configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME), 'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'support_url': configuration_helpers.get_value( 'support_url': configuration_helpers.get_value('SUPPORT_SITE_LINK', settings.SUPPORT_SITE_LINK),
'ACTIVATION_EMAIL_SUPPORT_LINK', settings.ACTIVATION_EMAIL_SUPPORT_LINK
) or settings.SUPPORT_SITE_LINK,
'support_email': configuration_helpers.get_value('CONTACT_EMAIL', settings.CONTACT_EMAIL), 'support_email': configuration_helpers.get_value('CONTACT_EMAIL', settings.CONTACT_EMAIL),
} }

View File

@@ -40,10 +40,3 @@ class RecoveryEmailCreate(BaseMessageType):
super(RecoveryEmailCreate, self).__init__(*args, **kwargs) super(RecoveryEmailCreate, self).__init__(*args, **kwargs)
self.options['transactional'] = True self.options['transactional'] = True
class AccountActivation(BaseMessageType):
def __init__(self, *args, **kwargs):
super(AccountActivation, self).__init__(*args, **kwargs)
self.options['transactional'] = True

View File

@@ -5,43 +5,30 @@ from __future__ import absolute_import
import logging import logging
from boto.exception import NoAuthHandlerFound
from celery.exceptions import MaxRetriesExceededError from celery.exceptions import MaxRetriesExceededError
from celery.task import task # pylint: disable=no-name-in-module, import-error from celery.task import task # pylint: disable=no-name-in-module, import-error
from django.conf import settings from django.conf import settings
from edx_ace import ace from django.core import mail
from edx_ace.errors import RecoverableChannelDeliveryError
from edx_ace.message import Message
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger('edx.celery.task') log = logging.getLogger('edx.celery.task')
@task(bind=True) @task(bind=True)
def send_activation_email(self, msg_string, from_address=None): def send_activation_email(self, subject, message, from_address, dest_addr):
""" """
Sending an activation email to the user. Sending an activation email to the user.
""" """
msg = Message.from_string(msg_string)
max_retries = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS max_retries = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
retries = self.request.retries retries = self.request.retries
if from_address is None:
from_address = configuration_helpers.get_value('ACTIVATION_EMAIL_FROM_ADDRESS') or (
configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
)
msg.options['from_address'] = from_address
dest_addr = msg.recipient.email_address
try: try:
ace.send(msg) mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
# Log that the Activation Email has been sent to user without an exception # Log that the Activation Email has been sent to user without an exception
log.info("Activation Email has been sent to User {user_email}".format( log.info("Activation Email has been sent to User {user_email}".format(
user_email=dest_addr user_email=dest_addr
)) ))
except RecoverableChannelDeliveryError: except NoAuthHandlerFound: # pylint: disable=broad-except
log.info('Retrying sending email to user {dest_addr}, attempt # {attempt} of {max_attempts}'.format( log.info('Retrying sending email to user {dest_addr}, attempt # {attempt} of {max_attempts}'. format(
dest_addr=dest_addr, dest_addr=dest_addr,
attempt=retries, attempt=retries,
max_attempts=max_retries max_attempts=max_retries

View File

@@ -25,12 +25,13 @@ from openedx.core.djangoapps.user_api.config.waffle import PREVENT_AUTH_USER_WRI
from openedx.core.djangolib.testing.utils import CacheIsolationMixin, CacheIsolationTestCase from openedx.core.djangolib.testing.utils import CacheIsolationMixin, CacheIsolationTestCase
from openedx.core.lib.request_utils import safe_get_host from openedx.core.lib.request_utils import safe_get_host
from student.models import PendingEmailChange, Registration, UserProfile from student.models import PendingEmailChange, Registration, UserProfile
from student.tests.factories import PendingEmailChangeFactory, UserFactory from student.tests.factories import PendingEmailChangeFactory, RegistrationFactory, UserFactory
from student.views import ( from student.views import (
SETTING_CHANGE_INITIATED, SETTING_CHANGE_INITIATED,
confirm_email_change, confirm_email_change,
do_email_change_request, do_email_change_request,
generate_activation_email_context, generate_activation_email_context,
send_reactivation_email_for_user,
validate_new_email validate_new_email
) )
from third_party_auth.views import inactive_user_view from third_party_auth.views import inactive_user_view
@@ -90,9 +91,8 @@ class EmailTestMixin(object):
self.addCleanup(settings.ALLOWED_HOSTS.pop) self.addCleanup(settings.ALLOWED_HOSTS.pop)
@ddt.ddt
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase): class ActivationEmailTests(CacheIsolationTestCase):
""" """
Test sending of the activation email. Test sending of the activation email.
""" """
@@ -102,36 +102,22 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase):
# Text fragments we expect in the body of an email # Text fragments we expect in the body of an email
# sent from an OpenEdX installation. # sent from an OpenEdX installation.
OPENEDX_FRAGMENTS = [ OPENEDX_FRAGMENTS = [
u"high-quality {platform} courses".format(platform=settings.PLATFORM_NAME),
"http://edx.org/activate/",
( (
u"Use the link below to activate your account to access engaging, " u"please use our web form at "
u"high-quality {platform_name} courses. Note that you will not be able to log back into your " u"{support_url} ".format(support_url=settings.SUPPORT_SITE_LINK)
u"account until you have activated it.".format( )
platform_name=settings.PLATFORM_NAME
)
),
u"{}/activate/".format(settings.LMS_ROOT_URL),
u"If you need help, please use our web form at ", (
settings.ACTIVATION_EMAIL_SUPPORT_LINK or settings.SUPPORT_SITE_LINK
),
settings.CONTACT_EMAIL,
u"This email message was automatically sent by ",
settings.LMS_ROOT_URL,
u" because someone attempted to create an account on {platform_name}".format(
platform_name=settings.PLATFORM_NAME
),
u" using this email address."
] ]
@ddt.data('plain_text', 'html') def test_activation_email(self):
def test_activation_email(self, test_body_type):
self._create_account() self._create_account()
self._assert_activation_email(self.ACTIVATION_SUBJECT, self.OPENEDX_FRAGMENTS, test_body_type) self._assert_activation_email(self.ACTIVATION_SUBJECT, self.OPENEDX_FRAGMENTS)
@with_comprehensive_theme("edx.org") @with_comprehensive_theme("edx.org")
@ddt.data('plain_text', 'html') def test_activation_email_edx_domain(self):
def test_activation_email_edx_domain(self, test_body_type):
self._create_account() self._create_account()
self._assert_activation_email(self.ACTIVATION_SUBJECT, self.OPENEDX_FRAGMENTS, test_body_type) self._assert_activation_email(self.ACTIVATION_SUBJECT, self.OPENEDX_FRAGMENTS)
def _create_account(self): def _create_account(self):
""" """
@@ -155,23 +141,15 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase):
) )
) )
def _assert_activation_email(self, subject, body_fragments, test_body_type): def _assert_activation_email(self, subject, body_fragments):
""" """
Verify that the activation email was sent. Verify that the activation email was sent.
""" """
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0] msg = mail.outbox[0]
self.assertEqual(msg.subject, subject) self.assertEqual(msg.subject, subject)
body_text = {
'plain_text': msg.body,
'html': msg.alternatives[0][0]
}
assert test_body_type in body_text
body_to_be_tested = body_text[test_body_type]
for fragment in body_fragments: for fragment in body_fragments:
self.assertIn(fragment, body_to_be_tested) self.assertIn(fragment, msg.body)
def test_do_not_send_email_and_do_activate(self): def test_do_not_send_email_and_do_activate(self):
""" """
@@ -219,6 +197,85 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase):
) )
@patch('student.views.management.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True))
@patch('django.contrib.auth.models.User.email_user')
class ReactivationEmailTests(EmailTestMixin, CacheIsolationTestCase):
"""
Test sending a reactivation email to a user
"""
def setUp(self):
super(ReactivationEmailTests, self).setUp()
self.user = UserFactory.create()
self.unregisteredUser = UserFactory.create()
self.registration = RegistrationFactory.create(user=self.user)
def reactivation_email(self, user):
"""
Send the reactivation email to the specified user,
and return the response as json data.
"""
return json.loads(send_reactivation_email_for_user(user).content.decode('utf-8'))
def assertReactivateEmailSent(self, email_user):
"""
Assert that the correct reactivation email has been sent
"""
context = generate_activation_email_context(self.user, self.registration)
self.assertEmailUser(
email_user,
'emails/activation_email_subject.txt',
context,
'emails/activation_email.txt',
context
)
# Thorough tests for safe_get_host are elsewhere; here we just want a quick URL sanity check
request = RequestFactory().post('unused_url')
request.user = self.user
request.META['HTTP_HOST'] = "aGenericValidHostName"
self.append_allowed_hosts("aGenericValidHostName")
with patch('edxmako.request_context.get_current_request', return_value=request):
body = render_to_string('emails/activation_email.txt', context)
host = safe_get_host(request)
self.assertIn(host, body)
def test_reactivation_email_failure(self, email_user):
self.user.email_user.side_effect = Exception
response_data = self.reactivation_email(self.user)
self.assertReactivateEmailSent(email_user)
self.assertFalse(response_data['success'])
def test_reactivation_for_unregistered_user(self, email_user): # pylint: disable=unused-argument
"""
Test that trying to send a reactivation email to an unregistered
user fails without throwing a 500 error.
"""
response_data = self.reactivation_email(self.unregisteredUser)
self.assertFalse(response_data['success'])
def test_reactivation_for_no_user_profile(self, email_user): # pylint: disable=unused-argument
"""
Test that trying to send a reactivation email to a user without
user profile fails without throwing 500 error.
"""
user = UserFactory.build(username='test_user', email='test_user@test.com')
user.save()
response_data = self.reactivation_email(user)
self.assertFalse(response_data['success'])
def test_reactivation_email_success(self, email_user):
response_data = self.reactivation_email(self.user)
self.assertReactivateEmailSent(email_user)
self.assertTrue(response_data['success'])
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS") @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
class EmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, CacheIsolationTestCase): class EmailChangeRequestTests(EventTestMixin, EmailTemplateTagMixin, CacheIsolationTestCase):
""" """

View File

@@ -5,15 +5,13 @@ Tests for the Sending activation email celery tasks
from __future__ import absolute_import from __future__ import absolute_import
import mock import mock
from boto.exception import NoAuthHandlerFound
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
from six.moves import range from six.moves import range
from edx_ace.errors import ChannelError, RecoverableChannelDeliveryError
from lms.djangoapps.courseware.tests.factories import UserFactory from lms.djangoapps.courseware.tests.factories import UserFactory
from student.models import Registration
from student.tasks import send_activation_email from student.tasks import send_activation_email
from student.views.management import compose_activation_email
class SendActivationEmailTestCase(TestCase): class SendActivationEmailTestCase(TestCase):
@@ -25,32 +23,18 @@ class SendActivationEmailTestCase(TestCase):
super(SendActivationEmailTestCase, self).setUp() super(SendActivationEmailTestCase, self).setUp()
self.student = UserFactory() self.student = UserFactory()
registration = Registration()
registration.register(self.student)
self.msg = compose_activation_email("http://www.example.com", self.student, registration)
def test_ComposeEmail(self):
"""
Tests that attributes of the message are being filled correctly in compose_activation_email
"""
self.assertEquals(self.msg.recipient.username, self.student.username)
self.assertEquals(self.msg.recipient.email_address, self.student.email)
self.assertEquals(self.msg.context['routed_user'], self.student.username)
self.assertEquals(self.msg.context['routed_user_email'], self.student.email)
self.assertEquals(self.msg.context['routed_profile_name'], '')
@mock.patch('time.sleep', mock.Mock(return_value=None)) @mock.patch('time.sleep', mock.Mock(return_value=None))
@mock.patch('student.tasks.log') @mock.patch('student.tasks.log')
@mock.patch('student.tasks.ace.send', mock.Mock(side_effect=RecoverableChannelDeliveryError(None, None))) @mock.patch('django.core.mail.send_mail', mock.Mock(side_effect=NoAuthHandlerFound))
def test_RetrySendUntilFail(self, mock_log): def test_send_email(self, mock_log):
""" """
Tests retries when the activation email doesn't send Tests retries when the activation email doesn't send
""" """
from_address = 'task_testing@example.com' from_address = 'task_testing@example.com'
email_max_attempts = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS email_max_attempts = settings.RETRY_ACTIVATION_EMAIL_MAX_ATTEMPTS
send_activation_email.delay(str(self.msg), from_address=from_address) # pylint: disable=no-member
send_activation_email.delay('Task_test', 'Task_test_message', from_address, self.student.email)
# Asserts sending email retry logging. # Asserts sending email retry logging.
for attempt in range(email_max_attempts): for attempt in range(email_max_attempts):
@@ -70,26 +54,3 @@ class SendActivationEmailTestCase(TestCase):
exc_info=True exc_info=True
) )
self.assertEquals(mock_log.error.call_count, 1) self.assertEquals(mock_log.error.call_count, 1)
@mock.patch('student.tasks.log')
@mock.patch('student.tasks.ace.send', mock.Mock(side_effect=ChannelError))
def test_UnrecoverableSendError(self, mock_log):
"""
Tests that a major failure of the send is logged
"""
from_address = 'task_testing@example.com'
send_activation_email.delay(str(self.msg), from_address=from_address)
# Asserts that the error was logged
mock_log.exception.assert_called_with(
'Unable to send activation email to user from "%s" to "%s"',
from_address,
self.student.email,
exc_info=True
)
# Assert that nothing else was logged
self.assertEquals(mock_log.info.call_count, 0)
self.assertEquals(mock_log.error.call_count, 0)
self.assertEquals(mock_log.exception.call_count, 1)

View File

@@ -66,13 +66,7 @@ from openedx.core.djangoapps.user_api.preferences import api as preferences_api
from openedx.core.djangolib.markup import HTML, Text from openedx.core.djangolib.markup import HTML, Text
from student.forms import AccountCreationForm, PasswordResetFormNoActive, get_registration_extension_form from student.forms import AccountCreationForm, PasswordResetFormNoActive, get_registration_extension_form
from student.helpers import DISABLE_UNENROLL_CERT_STATES, cert_info, generate_activation_email_context from student.helpers import DISABLE_UNENROLL_CERT_STATES, cert_info, generate_activation_email_context
from student.message_types import ( from student.message_types import EmailChange, EmailChangeConfirmation, PasswordReset, RecoveryEmailCreate
AccountActivation,
EmailChange,
EmailChangeConfirmation,
PasswordReset,
RecoveryEmailCreate
)
from student.models import ( from student.models import (
AccountRecovery, AccountRecovery,
CourseEnrollment, CourseEnrollment,
@@ -184,40 +178,6 @@ def index(request, extra_context=None, user=AnonymousUser()):
return render_to_response('index.html', context) return render_to_response('index.html', context)
def compose_activation_email(root_url, user, user_registration=None, route_enabled=False, profile_name=''):
"""
Construct all the required params for the activation email
through celery task
"""
if user_registration is None:
user_registration = Registration.objects.get(user=user)
message_context = generate_activation_email_context(user, user_registration)
message_context.update({
'confirm_activation_link': '{root_url}/activate/{activation_key}'.format(
root_url=root_url,
activation_key=message_context['key']
),
'route_enabled': route_enabled,
'routed_user': user.username,
'routed_user_email': user.email,
'routed_profile_name': profile_name,
})
if route_enabled:
dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']
else:
dest_addr = user.email
msg = AccountActivation().personalize(
recipient=Recipient(user.username, dest_addr),
language=preferences_api.get_user_preference(user, LANGUAGE_KEY),
user_context=message_context,
)
return msg
def compose_and_send_activation_email(user, profile, user_registration=None): def compose_and_send_activation_email(user, profile, user_registration=None):
""" """
Construct all the required params and send the activation email Construct all the required params and send the activation email
@@ -228,12 +188,66 @@ def compose_and_send_activation_email(user, profile, user_registration=None):
profile: profile object of the current logged-in user profile: profile object of the current logged-in user
user_registration: registration of the current logged-in user user_registration: registration of the current logged-in user
""" """
route_enabled = settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL') dest_addr = user.email
if user_registration is None:
user_registration = Registration.objects.get(user=user)
context = generate_activation_email_context(user, user_registration)
subject = render_to_string('emails/activation_email_subject.txt', context)
# Email subject *must not* contain newlines
subject = ''.join(subject.splitlines())
message_for_activation = render_to_string('emails/activation_email.txt', context)
from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
from_address = configuration_helpers.get_value('ACTIVATION_EMAIL_FROM_ADDRESS', from_address)
if settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL'):
dest_addr = settings.FEATURES['REROUTE_ACTIVATION_EMAIL']
message_for_activation = ("Activation for %s (%s): %s\n" % (user, user.email, profile.name) +
'-' * 80 + '\n\n' + message_for_activation)
send_activation_email.delay(subject, message_for_activation, from_address, dest_addr)
root_url = configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL)
msg = compose_activation_email(root_url, user, user_registration, route_enabled, profile.name)
send_activation_email.delay(str(msg)) def send_reactivation_email_for_user(user):
try:
registration = Registration.objects.get(user=user)
except Registration.DoesNotExist:
return JsonResponse({
"success": False,
"error": _('No inactive user with this e-mail exists'),
})
try:
context = generate_activation_email_context(user, registration)
except ObjectDoesNotExist:
log.error(
u'Unable to send reactivation email due to unavailable profile for the user "%s"',
user.username,
exc_info=True
)
return JsonResponse({
"success": False,
"error": _('Unable to send reactivation email')
})
subject = render_to_string('emails/activation_email_subject.txt', context)
subject = ''.join(subject.splitlines())
message = render_to_string('emails/activation_email.txt', context)
from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
from_address = configuration_helpers.get_value('ACTIVATION_EMAIL_FROM_ADDRESS', from_address)
try:
user.email_user(subject, message, from_address)
except Exception: # pylint: disable=broad-except
log.error(
u'Unable to send reactivation email from "%s" to "%s"',
from_address,
user.email,
exc_info=True
)
return JsonResponse({
"success": False,
"error": _('Unable to send reactivation email')
})
return JsonResponse({"success": True})
@login_required @login_required
@@ -537,9 +551,7 @@ def activate_account(request, key):
'{html_start}Your account could not be activated{html_end}' '{html_start}Your account could not be activated{html_end}'
'Something went wrong, please <a href="{support_url}">contact support</a> to resolve this issue.' 'Something went wrong, please <a href="{support_url}">contact support</a> to resolve this issue.'
)).format( )).format(
support_url=configuration_helpers.get_value( support_url=configuration_helpers.get_value('SUPPORT_SITE_LINK', settings.SUPPORT_SITE_LINK),
'ACTIVATION_EMAIL_SUPPORT_LINK', settings.ACTIVATION_EMAIL_SUPPORT_LINK
) or settings.SUPPORT_SITE_LINK,
html_start=HTML('<p class="message-title">'), html_start=HTML('<p class="message-title">'),
html_end=HTML('</p>'), html_end=HTML('</p>'),
), ),

View File

@@ -1,69 +0,0 @@
{% extends 'ace_common/edx_ace/common/base_body.html' %}
{% load django_markup %}
{% load i18n %}
{% load static %}
{% block content %}
<table width="100%" align="left" border="0" cellpadding="0" cellspacing="0" role="presentation">
{% if route_enabled %}
<tr>
<td>
<p style="color: rgba(0,0,0,.75);">
{% filter force_escape %}
{% blocktrans %}This is a routed Account Activation email for {{ routed_user }} ({{ routed_user_email }}): {{ routed_profile_name }}{% endblocktrans %}
{% endfilter %}
<br />
</p>
</td>
</tr>
{% endif %}
<tr>
<td>
<h1>
{% trans "Account Activation" as header_msg %}{{ header_msg | force_escape }}
</h1>
<p style="color: rgba(0,0,0,.75);">
{% filter force_escape %}
{% blocktrans %}You're almost there! Use the link below to activate your account to access engaging, high-quality {{ platform_name }} courses. Note that you will not be able to log back into your account until you have activated it.{% endblocktrans %}
{% endfilter %}
<br />
</p>
{% trans "Activate Your Account" as course_cta_text %}{{ course_cta_text | force_escape }}
{% include "ace_common/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text course_cta_url=confirm_activation_link %}
</td>
</tr>
<tr>
<td>
<p style="color: rgba(0,0,0,.75);">
{% filter force_escape %}
{% blocktrans %}Enjoy learning with {{ platform_name }}.{% endblocktrans %}
{% endfilter %}
<br />
</p>
</td>
</tr>
<td>
<p style="color: rgba(0,0,0,.75);">
{% blocktrans trimmed asvar assist_msg %}
If you need help, please use our web form at {start_anchor_web}{{ support_url }}{end_anchor} or email {start_anchor_email}{{ support_email }}{end_anchor}.
{% endblocktrans %}
{% interpolate_html assist_msg start_anchor_web='<a href="'|add:support_url|add:'">'|safe start_anchor_email='<a href="mailto:'|add:support_email|add:'">'|safe end_anchor='</a>'|safe %}
<br />
</p>
</td>
<tr>
</tr>
<tr>
<td>
<p style="color: rgba(0,0,0,.75);">
{% filter force_escape %}
{% blocktrans %}This email message was automatically sent by {{ lms_url }} because someone attempted to create an account on {{ platform_name }} using this email address.{% endblocktrans %}
{% endfilter %}
<br />
</p>
</td>
</tr>
</table>
{% endblock %}

View File

@@ -1,11 +0,0 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're almost there! Use the link below to activate your account to access engaging, high-quality {{ platform_name }} courses. Note that you will not be able to log back into your account until you have activated it.{% endblocktrans %}
{{ confirm_activation_link }}
{% blocktrans %}Enjoy learning with {{ platform_name }}.{% endblocktrans %}
{% blocktrans %}If you need help, please use our web form at {{ support_url }} or email {{ support_email }}.{% endblocktrans %}
{% blocktrans %}This email message was automatically sent by {{ lms_url }} because someone attempted to create an account on {{ platform_name }} using this email address.{% endblocktrans %}
{% endautoescape %}

View File

@@ -1 +0,0 @@
{{ platform_name }}

View File

@@ -1 +0,0 @@
{% extends 'ace_common/edx_ace/common/base_head.html' %}

View File

@@ -1,4 +0,0 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans trimmed %}Action Required: Activate your {{ platform_name }} account{% endblocktrans %}
{% endautoescape %}

View File

@@ -0,0 +1,16 @@
<%! from django.utils.translation import ugettext as _ %>
${_("Thank you for signing up for Open edX! To activate "
"your account, please copy and paste this address into your web "
"browser's address bar:")}
% if is_secure:
https://${ site }/activate/${ key }
% else:
http://${ site }/activate/${ key }
% endif
${_("If you didn't request this, you don't need to do anything; you won't "
"receive any more email from us. Please do not reply to this e-mail; "
"if you require assistance, check the help section of the "
"Open edX web site.")}

View File

@@ -0,0 +1,3 @@
<%! from django.utils.translation import ugettext as _ %>
${_("Your account for Open edX")}

View File

@@ -0,0 +1,24 @@
## mako
<%! from django.utils.translation import ugettext as _ %>
${_("You're almost there! Use the link to activate your account to access engaging, high-quality "
"{platform_name} courses. Note that you will not be able to log back into your account until "
"you have activated it.").format(platform_name=platform_name)}
% if is_secure:
https://${ site }/activate/${ key }
% else:
http://${ site }/activate/${ key }
% endif
${_("Enjoy learning with {platform_name}.").format(platform_name=platform_name)}
${_("The {platform_name} Team").format(platform_name=platform_name)}
${_("If you need help, please use our web form at {support_url} or email {support_email}.").format(
support_url=support_url, support_email=support_email
)}
${_("This email message was automatically sent by {lms_url} because someone attempted to create an "
"account on {platform_name} using this email address.").format(
lms_url=lms_url, platform_name=platform_name
)}

View File

@@ -0,0 +1,3 @@
## mako
<%! from django.utils.translation import ugettext as _ %>
${_("Action Required: Activate your {platform_name} account").format(platform_name=platform_name)}

View File

@@ -29,8 +29,8 @@ from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError
from openedx.core.djangoapps.util.user_messages import PageLevelMessages from openedx.core.djangoapps.util.user_messages import PageLevelMessages
from openedx.core.djangolib.markup import HTML, Text from openedx.core.djangolib.markup import HTML, Text
from student.forms import send_password_reset_email_for_user from student.forms import send_password_reset_email_for_user
from student.models import LoginFailures, UserProfile from student.models import LoginFailures
from student.views import compose_and_send_activation_email from student.views import send_reactivation_email_for_user
from third_party_auth import pipeline, provider from third_party_auth import pipeline, provider
from track import segment from track import segment
from util.json_request import JsonResponse from util.json_request import JsonResponse
@@ -166,9 +166,7 @@ def _log_and_raise_inactive_user_auth_error(unauthenticated_user):
unauthenticated_user.username) unauthenticated_user.username)
) )
profile = UserProfile.objects.get(user=unauthenticated_user) send_reactivation_email_for_user(unauthenticated_user)
compose_and_send_activation_email(unauthenticated_user, profile)
raise AuthFailedError(_generate_not_activated_message(unauthenticated_user)) raise AuthFailedError(_generate_not_activated_message(unauthenticated_user))

View File

@@ -19,7 +19,6 @@ from django.test.utils import override_settings
from django.urls import reverse from django.urls import reverse
from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY from lms.djangoapps.discussion.notification_prefs import NOTIFICATION_PREF_KEY
from openedx.core.djangoapps.ace_common.tests.mixins import EmailTemplateTagMixin
from openedx.core.djangoapps.django_comment_common.models import ForumsConfig from openedx.core.djangoapps.django_comment_common.models import ForumsConfig
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
@@ -92,7 +91,7 @@ def get_mock_pipeline_data(username=TEST_USERNAME, email=TEST_EMAIL):
] ]
} }
) )
class TestCreateAccount(EmailTemplateTagMixin, SiteMixin, TestCase): class TestCreateAccount(SiteMixin, TestCase):
"""Tests for account creation""" """Tests for account creation"""
def setUp(self): def setUp(self):