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
1c19ebb4
Commit
1c19ebb4
authored
May 17, 2016
by
asadiqbal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WL-477
parent
2282a299
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
18 deletions
+43
-18
common/djangoapps/student/forms.py
+2
-1
common/djangoapps/student/tests/test_email.py
+3
-2
common/djangoapps/student/tests/test_reset_password.py
+2
-1
common/djangoapps/student/views.py
+20
-7
lms/djangoapps/bulk_email/tasks.py
+5
-1
lms/djangoapps/instructor/enrollment.py
+2
-1
lms/djangoapps/instructor/views/api.py
+2
-1
lms/djangoapps/verify_student/views.py
+3
-2
openedx/core/djangoapps/credit/email_utils.py
+2
-1
openedx/core/djangoapps/user_api/accounts/api.py
+2
-1
No files found.
common/djangoapps/student/forms.py
View file @
1c19ebb4
...
...
@@ -24,6 +24,7 @@ from util.password_policy_validators import (
validate_password_complexity
,
validate_password_dictionary
,
)
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
class
PasswordResetFormNoActive
(
PasswordResetForm
):
...
...
@@ -57,7 +58,7 @@ class PasswordResetFormNoActive(PasswordResetForm):
email_template_name
=
'registration/password_reset_email.html'
,
use_https
=
False
,
token_generator
=
default_token_generator
,
from_email
=
settings
.
DEFAULT_FROM_EMAIL
,
from_email
=
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
,
request
=
None
):
"""
...
...
common/djangoapps/student/tests/test_email.py
View file @
1c19ebb4
...
...
@@ -22,6 +22,7 @@ from edxmako.tests import mako_middleware_process_request
from
util.request
import
safe_get_host
from
util.testing
import
EventTestMixin
from
openedx.core.djangoapps.theming.test_util
import
with_is_edx_domain
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
class
TestException
(
Exception
):
...
...
@@ -57,7 +58,7 @@ class EmailTestMixin(object):
email_user
.
assert_called_with
(
mock_render_to_string
(
subject_template
,
subject_context
),
mock_render_to_string
(
body_template
,
body_context
),
settings
.
DEFAULT_FROM_EMAIL
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
)
def
append_allowed_hosts
(
self
,
hostname
):
...
...
@@ -298,7 +299,7 @@ class EmailChangeRequestTests(EventTestMixin, TestCase):
send_mail
.
assert_called_with
(
mock_render_to_string
(
'emails/email_change_subject.txt'
,
context
),
mock_render_to_string
(
'emails/email_change.txt'
,
context
),
settings
.
DEFAULT_FROM_EMAIL
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
,
[
new_email
]
)
self
.
assert_event_emitted
(
...
...
common/djangoapps/student/tests/test_reset_password.py
View file @
1c19ebb4
...
...
@@ -26,6 +26,7 @@ from student.tests.test_email import mock_render_to_string
from
util.testing
import
EventTestMixin
from
.test_microsite
import
fake_microsite_get_value
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
@ddt.ddt
...
...
@@ -124,7 +125,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
(
subject
,
msg
,
from_addr
,
to_addrs
)
=
send_email
.
call_args
[
0
]
self
.
assertIn
(
"Password reset"
,
subject
)
self
.
assertIn
(
"You're receiving this e-mail because you requested a password reset"
,
msg
)
self
.
assertEquals
(
from_addr
,
settings
.
DEFAULT_FROM_EMAIL
)
self
.
assertEquals
(
from_addr
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
)
self
.
assertEquals
(
len
(
to_addrs
),
1
)
self
.
assertIn
(
self
.
user
.
email
,
to_addrs
)
...
...
common/djangoapps/student/views.py
View file @
1c19ebb4
...
...
@@ -128,6 +128,7 @@ from openedx.core.djangoapps.credit.email_utils import get_credit_provider_displ
from
openedx.core.djangoapps.user_api.preferences
import
api
as
preferences_api
from
openedx.core.djangoapps.programs.utils
import
get_programs_for_dashboard
,
get_display_category
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
"edx.student"
)
...
...
@@ -1789,7 +1790,7 @@ def create_account_with_params(request, params):
subject
=
''
.
join
(
subject
.
splitlines
())
message
=
render_to_string
(
'emails/activation_email.txt'
,
context
)
from_address
=
microsite
.
get_value
(
from_address
=
theming_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
...
...
@@ -2098,7 +2099,7 @@ def password_reset(request):
form
=
PasswordResetFormNoActive
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
(
use_https
=
request
.
is_secure
(),
from_email
=
microsite
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
),
from_email
=
theming_helpers
.
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.
...
...
@@ -2244,9 +2245,13 @@ def reactivation_email_for_user(user):
message
=
render_to_string
(
'emails/activation_email.txt'
,
context
)
try
:
user
.
email_user
(
subject
,
message
,
settings
.
DEFAULT_FROM_EMAIL
)
user
.
email_user
(
subject
,
message
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
)
except
Exception
:
# pylint: disable=broad-except
log
.
error
(
u'Unable to send reactivation email from "
%
s"'
,
settings
.
DEFAULT_FROM_EMAIL
,
exc_info
=
True
)
log
.
error
(
u'Unable to send reactivation email from "
%
s"'
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
),
exc_info
=
True
)
return
JsonResponse
({
"success"
:
False
,
"error"
:
_
(
'Unable to send reactivation email'
)
...
...
@@ -2304,7 +2309,7 @@ def do_email_change_request(user, new_email, activation_key=None):
message
=
render_to_string
(
'emails/email_change.txt'
,
context
)
from_address
=
microsite
.
get_value
(
from_address
=
theming_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
...
...
@@ -2365,7 +2370,11 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument
u_prof
.
save
()
# Send it to the old email...
try
:
user
.
email_user
(
subject
,
message
,
settings
.
DEFAULT_FROM_EMAIL
)
user
.
email_user
(
subject
,
message
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
)
except
Exception
:
# pylint: disable=broad-except
log
.
warning
(
'Unable to send confirmation email to old address'
,
exc_info
=
True
)
response
=
render_to_response
(
"email_change_failed.html"
,
{
'email'
:
user
.
email
})
...
...
@@ -2377,7 +2386,11 @@ def confirm_email_change(request, key): # pylint: disable=unused-argument
pec
.
delete
()
# And send it to the new email...
try
:
user
.
email_user
(
subject
,
message
,
settings
.
DEFAULT_FROM_EMAIL
)
user
.
email_user
(
subject
,
message
,
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
)
except
Exception
:
# pylint: disable=broad-except
log
.
warning
(
'Unable to send confirmation email to new address'
,
exc_info
=
True
)
response
=
render_to_response
(
"email_change_failed.html"
,
{
'email'
:
pec
.
new_email
})
...
...
lms/djangoapps/bulk_email/tasks.py
View file @
1c19ebb4
...
...
@@ -52,6 +52,7 @@ from instructor_task.subtasks import (
)
from
util.query
import
use_read_replica_if_available
from
util.date_utils
import
get_default_time_display
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
'edx.celery.task'
)
...
...
@@ -421,7 +422,10 @@ def _get_source_address(course_id, course_title, truncate=True):
return
from_addr_format
.
format
(
course_title
=
course_title_no_quotes
,
course_name
=
course_name
,
from_email
=
settings
.
BULK_EMAIL_DEFAULT_FROM_EMAIL
,
from_email
=
theming_helpers
.
get_value
(
'bulk_email_default_from_email'
,
settings
.
BULK_EMAIL_DEFAULT_FROM_EMAIL
)
)
from_addr
=
format_address
(
course_title_no_quotes
)
...
...
lms/djangoapps/instructor/enrollment.py
View file @
1c19ebb4
...
...
@@ -25,6 +25,7 @@ from openedx.core.djangoapps.user_api.models import UserPreference
from
microsite_configuration
import
microsite
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -426,7 +427,7 @@ def send_mail_to_student(student, param_dict, language=None):
# Email subject *must not* contain newlines
subject
=
''
.
join
(
subject
.
splitlines
())
from_address
=
microsite
.
get_value
(
from_address
=
theming_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
...
...
lms/djangoapps/instructor/views/api.py
View file @
1c19ebb4
...
...
@@ -109,6 +109,7 @@ from opaque_keys.edx.keys import CourseKey, UsageKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys
import
InvalidKeyError
from
openedx.core.djangoapps.course_groups.cohorts
import
is_course_cohorted
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -1733,7 +1734,7 @@ def generate_registration_codes(request, course_id):
log
.
exception
(
'Exception at creating pdf file.'
)
pdf_file
=
None
from_address
=
microsite
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
from_address
=
theming_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
context
=
{
'invoice'
:
sale_invoice
,
'site_name'
:
site_name
,
...
...
lms/djangoapps/verify_student/views.py
View file @
1c19ebb4
...
...
@@ -61,6 +61,7 @@ from util.date_utils import get_default_time_display
from
util.db
import
outer_atomic
from
xmodule.modulestore.django
import
modulestore
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -1100,7 +1101,7 @@ class SubmitPhotosView(View):
subject
=
_
(
"Verification photos received"
)
message
=
render_to_string
(
'emails/photo_submission_confirmation.txt'
,
context
)
from_address
=
microsite
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
from_address
=
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
to_address
=
user
.
email
try
:
...
...
@@ -1219,7 +1220,7 @@ def _send_email(user_id, subject, message):
Returns:
None
"""
from_address
=
microsite
.
get_value
(
from_address
=
theming_helpers
.
get_value
(
'email_from_address'
,
settings
.
DEFAULT_FROM_EMAIL
)
...
...
openedx/core/djangoapps/credit/email_utils.py
View file @
1c19ebb4
...
...
@@ -27,6 +27,7 @@ from microsite_configuration import microsite
from
openedx.core.djangoapps.commerce.utils
import
ecommerce_api_client
from
openedx.core.djangoapps.credit.models
import
CreditConfig
,
CreditProvider
from
xmodule.modulestore.django
import
modulestore
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -124,7 +125,7 @@ def send_credit_notifications(username, course_key):
notification_msg
.
attach
(
logo_image
)
# add email addresses of sender and receiver
from_address
=
microsite
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
from_address
=
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
to_address
=
user
.
email
# send the root email message
...
...
openedx/core/djangoapps/user_api/accounts/api.py
View file @
1c19ebb4
...
...
@@ -33,6 +33,7 @@ from .serializers import (
AccountLegacyProfileSerializer
,
AccountUserSerializer
,
UserReadOnlySerializer
,
_visible_fields
# pylint: disable=invalid-name
)
from
openedx.core.djangoapps.theming
import
helpers
as
theming_helpers
# Public access point for this function.
...
...
@@ -397,7 +398,7 @@ def request_password_change(email, orig_host, is_secure):
# Generate a single-use link for performing a password reset
# and email it to the user.
form
.
save
(
from_email
=
settings
.
DEFAULT_FROM_EMAIL
,
from_email
=
theming_helpers
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
,
domain_override
=
orig_host
,
use_https
=
is_secure
)
...
...
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