Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
cd56cc56
Commit
cd56cc56
authored
May 09, 2017
by
Matt Drayer
Committed by
GitHub
May 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15030 from edx/mattdrayer/ENT-318
ENT-318: Update activation email subject and message text
parents
3aba9da8
5e94c63d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
61 additions
and
40 deletions
+61
-40
cms/envs/common.py
+2
-0
common/djangoapps/student/tests/test_email.py
+6
-9
common/djangoapps/student/views.py
+22
-9
lms/envs/aws.py
+3
-0
lms/envs/common.py
+3
-0
lms/envs/test.py
+4
-0
lms/templates/emails/activation_email.txt
+17
-15
lms/templates/emails/activation_email_subject.txt
+1
-5
openedx/core/djangoapps/user_api/tests/test_helpers.py
+1
-0
openedx/core/djangoapps/user_api/tests/test_views.py
+2
-2
No files found.
cms/envs/common.py
View file @
cd56cc56
...
@@ -94,6 +94,8 @@ from lms.envs.common import (
...
@@ -94,6 +94,8 @@ from lms.envs.common import (
HELP_TOKENS_BOOKS
,
HELP_TOKENS_BOOKS
,
SUPPORT_SITE_LINK
,
SUPPORT_SITE_LINK
,
CONTACT_EMAIL
,
)
)
from
path
import
Path
as
path
from
path
import
Path
as
path
from
warnings
import
simplefilter
from
warnings
import
simplefilter
...
...
common/djangoapps/student/tests/test_email.py
View file @
cd56cc56
...
@@ -6,7 +6,7 @@ import mock
...
@@ -6,7 +6,7 @@ import mock
from
student.tests.factories
import
UserFactory
,
RegistrationFactory
,
PendingEmailChangeFactory
from
student.tests.factories
import
UserFactory
,
RegistrationFactory
,
PendingEmailChangeFactory
from
student.views
import
(
from
student.views
import
(
reactivation_email_for_user
,
do_email_change_request
,
confirm_email_change
,
reactivation_email_for_user
,
do_email_change_request
,
confirm_email_change
,
validate_new_email
,
SETTING_CHANGE_INITIATED
validate_new_email
,
SETTING_CHANGE_INITIATED
,
generate_activation_email_context
)
)
from
student.models
import
UserProfile
,
PendingEmailChange
,
Registration
from
student.models
import
UserProfile
,
PendingEmailChange
,
Registration
from
third_party_auth.views
import
inactive_user_view
from
third_party_auth.views
import
inactive_user_view
...
@@ -72,16 +72,16 @@ class EmailTestMixin(object):
...
@@ -72,16 +72,16 @@ class EmailTestMixin(object):
class
ActivationEmailTests
(
TestCase
):
class
ActivationEmailTests
(
TestCase
):
"""Test sending of the activation email. """
"""Test sending of the activation email. """
ACTIVATION_SUBJECT
=
u"Acti
vate Your {} A
ccount"
.
format
(
settings
.
PLATFORM_NAME
)
ACTIVATION_SUBJECT
=
u"Acti
on Required: Activate your {} a
ccount"
.
format
(
settings
.
PLATFORM_NAME
)
# 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"
Thank you for creating an account with {platform}!
"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
u"
high-quality {platform} courses
"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
"http://edx.org/activate/"
,
"http://edx.org/activate/"
,
(
(
"
Check the help section of the
"
"
please use our web form at
"
u"{
platform} website"
.
format
(
platform
=
settings
.
PLATFORM_NAME
)
u"{
support_url} "
.
format
(
support_url
=
settings
.
SUPPORT_SITE_LINK
)
)
)
]
]
...
@@ -170,10 +170,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
...
@@ -170,10 +170,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
def
assertReactivateEmailSent
(
self
,
email_user
):
def
assertReactivateEmailSent
(
self
,
email_user
):
"""Assert that the correct reactivation email has been sent"""
"""Assert that the correct reactivation email has been sent"""
context
=
{
context
=
generate_activation_email_context
(
self
.
user
,
self
.
registration
)
'name'
:
self
.
user
.
profile
.
name
,
'key'
:
self
.
registration
.
activation_key
}
self
.
assertEmailUser
(
self
.
assertEmailUser
(
email_user
,
email_user
,
...
...
common/djangoapps/student/views.py
View file @
cd56cc56
...
@@ -583,6 +583,24 @@ def is_course_blocked(request, redeemed_registration_codes, course_key):
...
@@ -583,6 +583,24 @@ def is_course_blocked(request, redeemed_registration_codes, course_key):
return
blocked
return
blocked
def
generate_activation_email_context
(
user
,
registration
):
"""
Constructs a dictionary for use in activation email contexts
Arguments:
user (User): Currently logged-in user
registration (Registration): Registration object for the currently logged-in user
"""
return
{
'name'
:
user
.
profile
.
name
,
'key'
:
registration
.
activation_key
,
'lms_url'
:
configuration_helpers
.
get_value
(
'LMS_ROOT_URL'
,
settings
.
LMS_ROOT_URL
),
'platform_name'
:
configuration_helpers
.
get_value
(
'PLATFORM_NAME'
,
settings
.
PLATFORM_NAME
),
'support_url'
:
configuration_helpers
.
get_value
(
'SUPPORT_SITE_LINK'
,
settings
.
SUPPORT_SITE_LINK
),
'support_email'
:
configuration_helpers
.
get_value
(
'CONTACT_EMAIL'
,
settings
.
CONTACT_EMAIL
),
}
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
...
@@ -596,10 +614,7 @@ def compose_and_send_activation_email(user, profile, user_registration=None):
...
@@ -596,10 +614,7 @@ def compose_and_send_activation_email(user, profile, user_registration=None):
dest_addr
=
user
.
email
dest_addr
=
user
.
email
if
user_registration
is
None
:
if
user_registration
is
None
:
user_registration
=
Registration
.
objects
.
get
(
user
=
user
)
user_registration
=
Registration
.
objects
.
get
(
user
=
user
)
context
=
{
context
=
generate_activation_email_context
(
user
,
user_registration
)
'name'
:
profile
.
name
,
'key'
:
user_registration
.
activation_key
,
}
subject
=
render_to_string
(
'emails/activation_email_subject.txt'
,
context
)
subject
=
render_to_string
(
'emails/activation_email_subject.txt'
,
context
)
# Email subject *must not* contain newlines
# Email subject *must not* contain newlines
subject
=
''
.
join
(
subject
.
splitlines
())
subject
=
''
.
join
(
subject
.
splitlines
())
...
@@ -2484,7 +2499,7 @@ def password_reset_confirm_wrapper(request, uidb36=None, token=None):
...
@@ -2484,7 +2499,7 @@ def password_reset_confirm_wrapper(request, uidb36=None, token=None):
def
reactivation_email_for_user
(
user
):
def
reactivation_email_for_user
(
user
):
try
:
try
:
reg
=
Registration
.
objects
.
get
(
user
=
user
)
reg
istration
=
Registration
.
objects
.
get
(
user
=
user
)
except
Registration
.
DoesNotExist
:
except
Registration
.
DoesNotExist
:
return
JsonResponse
({
return
JsonResponse
({
"success"
:
False
,
"success"
:
False
,
...
@@ -2492,10 +2507,7 @@ def reactivation_email_for_user(user):
...
@@ -2492,10 +2507,7 @@ def reactivation_email_for_user(user):
})
# TODO: this should be status code 400 # pylint: disable=fixme
})
# TODO: this should be status code 400 # pylint: disable=fixme
try
:
try
:
context
=
{
context
=
generate_activation_email_context
(
user
,
registration
)
'name'
:
user
.
profile
.
name
,
'key'
:
reg
.
activation_key
,
}
except
ObjectDoesNotExist
:
except
ObjectDoesNotExist
:
log
.
error
(
log
.
error
(
u'Unable to send reactivation email due to unavailable profile for the user "
%
s"'
,
u'Unable to send reactivation email due to unavailable profile for the user "
%
s"'
,
...
@@ -2511,6 +2523,7 @@ def reactivation_email_for_user(user):
...
@@ -2511,6 +2523,7 @@ def reactivation_email_for_user(user):
subject
=
''
.
join
(
subject
.
splitlines
())
subject
=
''
.
join
(
subject
.
splitlines
())
message
=
render_to_string
(
'emails/activation_email.txt'
,
context
)
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
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
from_address
=
configuration_helpers
.
get_value
(
'ACTIVATION_EMAIL_FROM_ADDRESS'
,
from_address
)
try
:
try
:
user
.
email_user
(
subject
,
message
,
from_address
)
user
.
email_user
(
subject
,
message
,
from_address
)
...
...
lms/envs/aws.py
View file @
cd56cc56
...
@@ -234,6 +234,9 @@ PRESS_EMAIL = ENV_TOKENS.get('PRESS_EMAIL', PRESS_EMAIL)
...
@@ -234,6 +234,9 @@ PRESS_EMAIL = ENV_TOKENS.get('PRESS_EMAIL', PRESS_EMAIL)
CONTACT_MAILING_ADDRESS
=
ENV_TOKENS
.
get
(
'CONTACT_MAILING_ADDRESS'
,
CONTACT_MAILING_ADDRESS
)
CONTACT_MAILING_ADDRESS
=
ENV_TOKENS
.
get
(
'CONTACT_MAILING_ADDRESS'
,
CONTACT_MAILING_ADDRESS
)
# Account activation email sender address
ACTIVATION_EMAIL_FROM_ADDRESS
=
ENV_TOKENS
.
get
(
'ACTIVATION_EMAIL_FROM_ADDRESS'
,
ACTIVATION_EMAIL_FROM_ADDRESS
)
# Currency
# Currency
PAID_COURSE_REGISTRATION_CURRENCY
=
ENV_TOKENS
.
get
(
'PAID_COURSE_REGISTRATION_CURRENCY'
,
PAID_COURSE_REGISTRATION_CURRENCY
=
ENV_TOKENS
.
get
(
'PAID_COURSE_REGISTRATION_CURRENCY'
,
PAID_COURSE_REGISTRATION_CURRENCY
)
PAID_COURSE_REGISTRATION_CURRENCY
)
...
...
lms/envs/common.py
View file @
cd56cc56
...
@@ -838,6 +838,9 @@ FINANCE_EMAIL = ''
...
@@ -838,6 +838,9 @@ FINANCE_EMAIL = ''
# Platform mailing address
# Platform mailing address
CONTACT_MAILING_ADDRESS
=
''
CONTACT_MAILING_ADDRESS
=
''
# Account activation email sender address
ACTIVATION_EMAIL_FROM_ADDRESS
=
''
ADMINS
=
()
ADMINS
=
()
MANAGERS
=
ADMINS
MANAGERS
=
ADMINS
...
...
lms/envs/test.py
View file @
cd56cc56
...
@@ -443,6 +443,7 @@ MICROSITE_CONFIGURATION = {
...
@@ -443,6 +443,7 @@ MICROSITE_CONFIGURATION = {
"platform_name"
:
"Test Site"
,
"platform_name"
:
"Test Site"
,
"logo_image_url"
:
"test_site/images/header-logo.png"
,
"logo_image_url"
:
"test_site/images/header-logo.png"
,
"email_from_address"
:
"test_site@edx.org"
,
"email_from_address"
:
"test_site@edx.org"
,
"ACTIVATION_EMAIL_FROM_ADDRESS"
:
"test_activate@edx.org"
,
"payment_support_email"
:
"test_site@edx.org"
,
"payment_support_email"
:
"test_site@edx.org"
,
"ENABLE_MKTG_SITE"
:
False
,
"ENABLE_MKTG_SITE"
:
False
,
"SITE_NAME"
:
"test_site.localhost"
,
"SITE_NAME"
:
"test_site.localhost"
,
...
@@ -474,6 +475,7 @@ MICROSITE_CONFIGURATION = {
...
@@ -474,6 +475,7 @@ MICROSITE_CONFIGURATION = {
"platform_name"
:
"Test logistration"
,
"platform_name"
:
"Test logistration"
,
"logo_image_url"
:
"test_site/images/header-logo.png"
,
"logo_image_url"
:
"test_site/images/header-logo.png"
,
"email_from_address"
:
"test_site@edx.org"
,
"email_from_address"
:
"test_site@edx.org"
,
"ACTIVATION_EMAIL_FROM_ADDRESS"
:
"test_activate@edx.org"
,
"payment_support_email"
:
"test_site@edx.org"
,
"payment_support_email"
:
"test_site@edx.org"
,
"ENABLE_MKTG_SITE"
:
False
,
"ENABLE_MKTG_SITE"
:
False
,
"ENABLE_COMBINED_LOGIN_REGISTRATION"
:
True
,
"ENABLE_COMBINED_LOGIN_REGISTRATION"
:
True
,
...
@@ -596,3 +598,5 @@ LMS_ROOT_URL = "http://localhost:8000"
...
@@ -596,3 +598,5 @@ LMS_ROOT_URL = "http://localhost:8000"
ECOMMERCE_API_URL
=
'https://ecommerce.example.com/api/v2/'
ECOMMERCE_API_URL
=
'https://ecommerce.example.com/api/v2/'
ENTERPRISE_API_URL
=
'http://enterprise.example.com/enterprise/api/v1/'
ENTERPRISE_API_URL
=
'http://enterprise.example.com/enterprise/api/v1/'
ACTIVATION_EMAIL_FROM_ADDRESS
=
'test_activate@edx.org'
lms/templates/emails/activation_email.txt
View file @
cd56cc56
<%! from django.utils.translation import ugettext as _ %>
<%! from django.utils.translation import ugettext as _ %>
<%! from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers %>
${_("You're almost there! Use the link to activate your account to access engaging, high-quality "
${_("Thank you for creating an account with {platform_name}!").format(
"{platform_name} courses. Note that you will not be able to log back into your account until "
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
"you have activated it.").format(platform_name=platform_name)}
)}
${_("There's just one more step before you can enroll in a course: "
"you need to activate your {platform_name} account. To activate "
"your account, click the following link. If that doesn't work, "
"copy and paste the link into your browser's address bar.").format(
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
)}
% if is_secure:
% if is_secure:
https://${ site }/activate/${ key }
https://${ site }/activate/${ key }
% else:
% else:
http://${ site }/activate/${ key }
http://${ site }/activate/${ key }
% endif
% endif
${_("If you didn't create an account, you don't need to do anything; you "
"won't receive any more email from us. If you need assistance, please "
${_("Enjoy learning with {platform_name}.").format(platform_name=platform_name)}
"do not reply to this email message. Check the help section of the "
"{platform_name} website.").format(platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.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
)}
\ No newline at end of file
lms/templates/emails/activation_email_subject.txt
View file @
cd56cc56
<%! from django.utils.translation import ugettext as _ %>
<%! from django.utils.translation import ugettext as _ %>
<%! from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers %>
${_("Action Required: Activate your {platform_name} account").format(platform_name=platform_name)}
${_("Activate Your {platform_name} Account").format(
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME
))}
openedx/core/djangoapps/user_api/tests/test_helpers.py
View file @
cd56cc56
...
@@ -53,6 +53,7 @@ class InterceptErrorsTest(TestCase):
...
@@ -53,6 +53,7 @@ class InterceptErrorsTest(TestCase):
@mock.patch
(
'openedx.core.djangoapps.user_api.helpers.LOGGER'
)
@mock.patch
(
'openedx.core.djangoapps.user_api.helpers.LOGGER'
)
def
test_logs_errors
(
self
,
mock_logger
):
def
test_logs_errors
(
self
,
mock_logger
):
self
.
maxDiff
=
None
exception
=
'openedx.core.djangoapps.user_api.tests.test_helpers.FakeInputException'
exception
=
'openedx.core.djangoapps.user_api.tests.test_helpers.FakeInputException'
expected_log_msg
=
(
expected_log_msg
=
(
u"An unexpected error occurred when calling 'intercepted_function' with arguments '()' and "
u"An unexpected error occurred when calling 'intercepted_function' with arguments '()' and "
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
cd56cc56
...
@@ -1625,10 +1625,10 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1625,10 +1625,10 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
self
.
assertEqual
(
sent_email
.
to
,
[
self
.
EMAIL
])
self
.
assertEqual
(
sent_email
.
to
,
[
self
.
EMAIL
])
self
.
assertEqual
(
self
.
assertEqual
(
sent_email
.
subject
,
sent_email
.
subject
,
u"Acti
vate Your {platform} A
ccount"
.
format
(
platform
=
settings
.
PLATFORM_NAME
)
u"Acti
on Required: Activate your {platform} a
ccount"
.
format
(
platform
=
settings
.
PLATFORM_NAME
)
)
)
self
.
assertIn
(
self
.
assertIn
(
u"
you need to activate your {platform} account
"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
u"
high-quality {platform} courses
"
.
format
(
platform
=
settings
.
PLATFORM_NAME
),
sent_email
.
body
sent_email
.
body
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment