Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
eb9c7c17
Commit
eb9c7c17
authored
Feb 24, 2017
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed course team from studio instance email.
ECOM-7233
parent
a564e3b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
40 deletions
+38
-40
course_discovery/apps/publisher/emails.py
+34
-35
course_discovery/apps/publisher/tests/test_emails.py
+1
-2
course_discovery/apps/publisher/tests/test_views.py
+3
-3
No files found.
course_discovery/apps/publisher/emails.py
View file @
eb9c7c17
...
...
@@ -67,46 +67,45 @@ def send_email_for_course_creation(course, course_run):
course (Course): Course object
course_run (CourseRun): CourseRun object
"""
try
:
txt_template
=
'publisher/email/course_created.txt'
html_template
=
'publisher/email/course_created.html'
txt_template
=
'publisher/email/course_created.txt'
html_template
=
'publisher/email/course_created.html'
to_addresses
=
course
.
get_course_users_emails
()
from_address
=
settings
.
PUBLISHER_FROM_EMAIL
subject
=
_
(
'New Studio instance request for {title}'
)
.
format
(
title
=
course
.
title
)
# pylint: disable=no-member
project_coordinator
=
course
.
project_coordinator
course_team
=
course
.
course_team_admin
course_user_roles
=
course_run
.
course
.
course_user_roles
.
all
()
course_team
=
course_user_roles
.
filter
(
role
=
PublisherUserRole
.
CourseTeam
)
.
first
()
project_coordinator
=
course_user_roles
.
filter
(
role
=
PublisherUserRole
.
ProjectCoordinator
)
.
first
()
context
=
{
'course_title'
:
course_run
.
course
.
title
,
'date'
:
course_run
.
created
.
strftime
(
"
%
B
%
d,
%
Y"
),
'time'
:
course_run
.
created
.
strftime
(
"
%
H:
%
M:
%
S"
),
'course_team_name'
:
course_team
.
user
.
full_name
if
course_team
else
''
,
'project_coordinator_name'
:
project_coordinator
.
user
.
full_name
if
project_coordinator
else
''
,
'dashboard_url'
:
'https://{host}{path}'
.
format
(
host
=
Site
.
objects
.
get_current
()
.
domain
.
strip
(
'/'
),
path
=
reverse
(
'publisher:publisher_dashboard'
)
),
'from_address'
:
from_address
,
'contact_us_email'
:
project_coordinator
.
user
.
email
if
project_coordinator
else
''
}
if
is_email_notification_enabled
(
project_coordinator
):
try
:
to_addresses
=
[
project_coordinator
.
email
]
from_address
=
settings
.
PUBLISHER_FROM_EMAIL
template
=
get_template
(
txt_template
)
plain_content
=
template
.
render
(
context
)
template
=
get_template
(
html_template
)
html_content
=
template
.
render
(
context
)
context
=
{
'course_title'
:
course_run
.
course
.
title
,
'date'
:
course_run
.
created
.
strftime
(
"
%
B
%
d,
%
Y"
),
'time'
:
course_run
.
created
.
strftime
(
"
%
H:
%
M:
%
S"
),
'course_team_name'
:
course_team
.
get_full_name
(),
'project_coordinator_name'
:
project_coordinator
.
get_full_name
(),
'dashboard_url'
:
'https://{host}{path}'
.
format
(
host
=
Site
.
objects
.
get_current
()
.
domain
.
strip
(
'/'
),
path
=
reverse
(
'publisher:publisher_dashboard'
)
),
'from_address'
:
from_address
,
'contact_us_email'
:
project_coordinator
.
email
}
subject
=
_
(
'New Studio instance request for {title}'
)
.
format
(
title
=
course
.
title
)
# pylint: disable=no-member
template
=
get_template
(
txt_template
)
plain_content
=
template
.
render
(
context
)
template
=
get_template
(
html_template
)
html_content
=
template
.
render
(
context
)
email_msg
=
EmailMultiAlternatives
(
subject
,
plain_content
,
from_address
,
to
=
[
settings
.
PUBLISHER_FROM_EMAIL
],
bcc
=
to_addresses
)
email_msg
.
attach_alternative
(
html_content
,
'text/html'
)
email_msg
.
send
()
except
Exception
:
# pylint: disable=broad-except
logger
.
exception
(
'Failed to send email notifications for creation of course [
%
s]'
,
course_run
.
course
.
id
)
email_msg
=
EmailMultiAlternatives
(
subject
,
plain_content
,
from_address
,
to
=
to_addresses
)
email_msg
.
attach_alternative
(
html_content
,
'text/html'
)
email_msg
.
send
()
except
Exception
:
# pylint: disable=broad-except
logger
.
exception
(
'Failed to send email notifications for creation of course [
%
s]'
,
course_run
.
course
.
id
)
def
send_email_for_send_for_review
(
course
,
user
):
...
...
course_discovery/apps/publisher/tests/test_emails.py
View file @
eb9c7c17
...
...
@@ -132,8 +132,7 @@ class CourseCreatedEmailTests(TestCase):
def
assert_email_sent
(
self
,
subject
):
""" Verify the email data for tests cases."""
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
([
settings
.
PUBLISHER_FROM_EMAIL
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
([
self
.
user
.
email
,
self
.
course_team
.
email
],
mail
.
outbox
[
0
]
.
bcc
)
self
.
assertEqual
([
self
.
user
.
email
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
subject
)
body
=
mail
.
outbox
[
0
]
.
body
.
strip
()
...
...
course_discovery/apps/publisher/tests/test_views.py
View file @
eb9c7c17
...
...
@@ -335,9 +335,9 @@ class CreateCourseViewTests(TestCase):
self
.
_assert_records
(
2
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
'New Studio instance request for {title}'
.
format
(
title
=
course
.
title
)
)
self
.
assertEqual
(
[
course
.
project_coordinator
.
email
],
mail
.
outbox
[
0
]
.
to
)
expected_subject
=
'New Studio instance request for {title}'
.
format
(
title
=
course
.
title
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
expected_subject
)
class
CreateCourseRunViewTests
(
TestCase
):
...
...
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