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
05bfd80f
Commit
05bfd80f
authored
Aug 09, 2016
by
Cliff Dyer
Committed by
GitHub
Aug 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12934 from open-craft/jill/fix-bulk-email-url-scheme
Use appropriate URL scheme for bulk emails
parents
95b16dba
cf8e0e44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
6 deletions
+63
-6
lms/djangoapps/bulk_email/tasks.py
+5
-5
lms/djangoapps/bulk_email/tests/test_email.py
+58
-1
No files found.
lms/djangoapps/bulk_email/tasks.py
View file @
05bfd80f
...
...
@@ -100,18 +100,18 @@ def _get_course_email_context(course):
course_id
=
course
.
id
.
to_deprecated_string
()
course_title
=
course
.
display_name
course_end_date
=
get_default_time_display
(
course
.
end
)
course_url
=
'
https://
{}{}'
.
format
(
settings
.
SITE_NAME
,
course_url
=
'{}{}'
.
format
(
settings
.
LMS_ROOT_URL
,
reverse
(
'course_root'
,
kwargs
=
{
'course_id'
:
course_id
})
)
image_url
=
u'
https://{}{}'
.
format
(
settings
.
SITE_NAME
,
course_image_url
(
course
))
image_url
=
u'
{}{}'
.
format
(
settings
.
LMS_ROOT_URL
,
course_image_url
(
course
))
email_context
=
{
'course_title'
:
course_title
,
'course_url'
:
course_url
,
'course_image_url'
:
image_url
,
'course_end_date'
:
course_end_date
,
'account_settings_url'
:
'
https://{}{}'
.
format
(
settings
.
SITE_NAME
,
reverse
(
'account_settings'
)),
'email_settings_url'
:
'
https://{}{}'
.
format
(
settings
.
SITE_NAME
,
reverse
(
'dashboard'
)),
'account_settings_url'
:
'
{}{}'
.
format
(
settings
.
LMS_ROOT_URL
,
reverse
(
'account_settings'
)),
'email_settings_url'
:
'
{}{}'
.
format
(
settings
.
LMS_ROOT_URL
,
reverse
(
'dashboard'
)),
'platform_name'
:
configuration_helpers
.
get_value
(
'PLATFORM_NAME'
,
settings
.
PLATFORM_NAME
),
}
return
email_context
...
...
lms/djangoapps/bulk_email/tests/test_email.py
View file @
05bfd80f
...
...
@@ -16,7 +16,7 @@ from django.core.management import call_command
from
django.test.utils
import
override_settings
from
bulk_email.models
import
Optout
,
BulkEmailFlag
from
bulk_email.tasks
import
_get_source_address
from
bulk_email.tasks
import
_get_source_address
,
_get_course_email_context
from
openedx.core.djangoapps.course_groups.models
import
CourseCohort
from
openedx.core.djangoapps.course_groups.cohorts
import
add_user_to_cohort
from
courseware.tests.factories
import
StaffFactory
,
InstructorFactory
...
...
@@ -475,3 +475,60 @@ class TestEmailSendFromDashboard(EmailSendFromDashboardTestCase):
message_body
=
mail
.
outbox
[
0
]
.
body
self
.
assertIn
(
uni_message
,
message_body
)
class
TestCourseEmailContext
(
SharedModuleStoreTestCase
):
"""
Test the course email context hash used to send bulk emails.
"""
@classmethod
def
setUpClass
(
cls
):
"""
Create a course shared by all tests.
"""
super
(
TestCourseEmailContext
,
cls
)
.
setUpClass
()
cls
.
course_title
=
u"Финансовое программирование и политика, часть 1: макроэкономические счета и анализ"
cls
.
course_org
=
'IMF'
cls
.
course_number
=
"FPP.1x"
cls
.
course_run
=
"2016"
cls
.
course
=
CourseFactory
.
create
(
display_name
=
cls
.
course_title
,
org
=
cls
.
course_org
,
number
=
cls
.
course_number
,
run
=
cls
.
course_run
,
)
def
verify_email_context
(
self
,
email_context
,
scheme
):
"""
This test tests that the bulk email context uses http or https urls as appropriate.
"""
self
.
assertEquals
(
email_context
[
'platform_name'
],
'edX'
)
self
.
assertEquals
(
email_context
[
'course_title'
],
self
.
course_title
)
self
.
assertEquals
(
email_context
[
'course_url'
],
'{}://edx.org/courses/{}/{}/{}/'
.
format
(
scheme
,
self
.
course_org
,
self
.
course_number
,
self
.
course_run
))
self
.
assertEquals
(
email_context
[
'course_image_url'
],
'{}://edx.org/c4x/{}/{}/asset/images_course_image.jpg'
.
format
(
scheme
,
self
.
course_org
,
self
.
course_number
))
self
.
assertEquals
(
email_context
[
'email_settings_url'
],
'{}://edx.org/dashboard'
.
format
(
scheme
))
self
.
assertEquals
(
email_context
[
'account_settings_url'
],
'{}://edx.org/account/settings'
.
format
(
scheme
))
@override_settings
(
LMS_ROOT_URL
=
"http://edx.org"
)
def
test_insecure_email_context
(
self
):
"""
This test tests that the bulk email context uses http urls
"""
email_context
=
_get_course_email_context
(
self
.
course
)
self
.
verify_email_context
(
email_context
,
'http'
)
@override_settings
(
LMS_ROOT_URL
=
"https://edx.org"
)
def
test_secure_email_context
(
self
):
"""
This test tests that the bulk email context uses https urls
"""
email_context
=
_get_course_email_context
(
self
.
course
)
self
.
verify_email_context
(
email_context
,
'https'
)
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