diff --git a/common/djangoapps/student/views/management.py b/common/djangoapps/student/views/management.py index 2b0c21bfbf..eac799c5e1 100644 --- a/common/djangoapps/student/views/management.py +++ b/common/djangoapps/student/views/management.py @@ -172,14 +172,14 @@ def index(request, extra_context=None, user=AnonymousUser()): return render_to_response('index.html', context) -def compose_activation_email(user, user_registration=None, route_enabled=False, profile_name='', redirect_url=None): +def compose_activation_email( + user, user_registration=None, route_enabled=False, profile_name='', redirect_url=None, registration_flow=False +): """ Construct all the required params for the activation email through celery task """ - registration_flow = True if user_registration is None: - registration_flow = False user_registration = Registration.objects.get(user=user) message_context = generate_activation_email_context(user, user_registration) @@ -190,6 +190,7 @@ def compose_activation_email(user, user_registration=None, route_enabled=False, 'routed_user_email': user.email, 'routed_profile_name': profile_name, 'registration_flow': registration_flow, + 'is_enterprise_learner': is_enterprise_learner(user), }) if route_enabled: @@ -225,7 +226,9 @@ def _get_activation_confirmation_link(activation_key, redirect_url=None): return urllib.parse.urlunparse((scheme, netloc, path, params, query, fragment)) -def compose_and_send_activation_email(user, profile, user_registration=None, redirect_url=None): +def compose_and_send_activation_email( + user, profile, user_registration=None, redirect_url=None, registration_flow=False, +): """ Construct all the required params and send the activation email through celery task @@ -235,10 +238,13 @@ def compose_and_send_activation_email(user, profile, user_registration=None, red profile: profile object of the current logged-in user user_registration: registration of the current logged-in user redirect_url: The URL to redirect to after successful activation + registration_flow: Is the request coming from registration workflow """ route_enabled = settings.FEATURES.get('REROUTE_ACTIVATION_EMAIL') - msg = compose_activation_email(user, user_registration, route_enabled, profile.name, redirect_url) + msg = compose_activation_email( + user, user_registration, route_enabled, profile.name, redirect_url, registration_flow + ) from_address = configuration_helpers.get_value('ACTIVATION_EMAIL_FROM_ADDRESS') or ( configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL) ) diff --git a/openedx/core/djangoapps/user_authn/tests/test_tasks.py b/openedx/core/djangoapps/user_authn/tests/test_tasks.py index 7598448412..80516f20a3 100644 --- a/openedx/core/djangoapps/user_authn/tests/test_tasks.py +++ b/openedx/core/djangoapps/user_authn/tests/test_tasks.py @@ -42,7 +42,8 @@ class SendActivationEmailTestCase(TestCase): assert self.msg.context['routed_user'] == self.student.username assert self.msg.context['routed_user_email'] == self.student.email assert self.msg.context['routed_profile_name'] == '' - assert self.msg.context['registration_flow'] is True + assert self.msg.context['registration_flow'] is False + assert self.msg.context['is_enterprise_learner'] is False @mock.patch('time.sleep', mock.Mock(return_value=None)) @mock.patch('openedx.core.djangoapps.user_authn.tasks.log') diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index c7889d96a7..a0e56fb438 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -247,7 +247,7 @@ def create_account_with_params(request, params): # pylint: disable=too-many-sta else: redirect_to, root_url = get_next_url_for_login_page(request, include_host=True) redirect_url = get_redirect_url_with_host(root_url, redirect_to) - compose_and_send_activation_email(user, profile, registration, redirect_url) + compose_and_send_activation_email(user, profile, registration, redirect_url, True) if settings.FEATURES.get('ENABLE_DISCUSSION_EMAIL_DIGEST'): try: