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
0c502bdb
Commit
0c502bdb
authored
Apr 18, 2017
by
tasawernawaz
Committed by
Tasawer Nawaz
Apr 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Studio instance created email should only go to course team
ECOM-7690
parent
a85335ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
course_discovery/apps/publisher/api/tests/test_views.py
+6
-3
course_discovery/apps/publisher/emails.py
+2
-4
course_discovery/apps/publisher/tests/test_emails.py
+1
-3
No files found.
course_discovery/apps/publisher/api/tests/test_views.py
View file @
0c502bdb
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
json
import
json
import
ddt
import
ddt
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
from
django.contrib.auth.models
import
Group
from
django.contrib.sites.models
import
Site
from
django.contrib.sites.models
import
Site
from
django.core
import
mail
from
django.core
import
mail
...
@@ -267,6 +266,11 @@ class UpdateCourseRunViewTests(TestCase):
...
@@ -267,6 +266,11 @@ class UpdateCourseRunViewTests(TestCase):
# By default `lms_course_id` and `changed_by` are None
# By default `lms_course_id` and `changed_by` are None
self
.
assert_course_key_and_changed_by
()
self
.
assert_course_key_and_changed_by
()
# create course team role for email
factories
.
CourseUserRoleFactory
(
course
=
self
.
course_run
.
course
,
role
=
PublisherUserRole
.
CourseTeam
,
user
=
self
.
user
)
lms_course_id
=
'course-v1:edxTest+TC12+2050Q1'
lms_course_id
=
'course-v1:edxTest+TC12+2050Q1'
response
=
self
.
client
.
patch
(
response
=
self
.
client
.
patch
(
self
.
update_course_run_url
,
self
.
update_course_run_url
,
...
@@ -297,8 +301,7 @@ class UpdateCourseRunViewTests(TestCase):
...
@@ -297,8 +301,7 @@ class UpdateCourseRunViewTests(TestCase):
Helper method to assert sent email data.
Helper method to assert sent email data.
"""
"""
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
([
settings
.
PUBLISHER_FROM_EMAIL
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
([
self
.
user
.
email
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
([
self
.
user
.
email
],
mail
.
outbox
[
0
]
.
bcc
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
subject
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
subject
)
body
=
mail
.
outbox
[
0
]
.
body
.
strip
()
body
=
mail
.
outbox
[
0
]
.
body
.
strip
()
...
...
course_discovery/apps/publisher/emails.py
View file @
0c502bdb
...
@@ -25,7 +25,7 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
...
@@ -25,7 +25,7 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
object_path
=
reverse
(
'publisher:publisher_course_run_detail'
,
kwargs
=
{
'pk'
:
course_run
.
id
})
object_path
=
reverse
(
'publisher:publisher_course_run_detail'
,
kwargs
=
{
'pk'
:
course_run
.
id
})
subject
=
_
(
'Studio instance {updated_text}'
)
.
format
(
updated_text
=
updated_text
)
# pylint: disable=no-member
subject
=
_
(
'Studio instance {updated_text}'
)
.
format
(
updated_text
=
updated_text
)
# pylint: disable=no-member
to_addresses
=
course_run
.
course
.
get_course_users_emails
()
to_addresses
=
[
course_run
.
course
.
course_team_admin
.
email
]
from_address
=
settings
.
PUBLISHER_FROM_EMAIL
from_address
=
settings
.
PUBLISHER_FROM_EMAIL
course_user_roles
=
course_run
.
course
.
course_user_roles
.
all
()
course_user_roles
=
course_run
.
course
.
course_user_roles
.
all
()
...
@@ -52,9 +52,7 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
...
@@ -52,9 +52,7 @@ def send_email_for_studio_instance_created(course_run, updated_text=_('created')
plain_content
=
txt_template
.
render
(
context
)
plain_content
=
txt_template
.
render
(
context
)
html_template
=
get_template
(
html_template_path
)
html_template
=
get_template
(
html_template_path
)
html_content
=
html_template
.
render
(
context
)
html_content
=
html_template
.
render
(
context
)
email_msg
=
EmailMultiAlternatives
(
email_msg
=
EmailMultiAlternatives
(
subject
,
plain_content
,
from_address
,
to
=
to_addresses
)
subject
,
plain_content
,
from_address
,
to
=
[
settings
.
PUBLISHER_FROM_EMAIL
],
bcc
=
to_addresses
)
email_msg
.
attach_alternative
(
html_content
,
'text/html'
)
email_msg
.
attach_alternative
(
html_content
,
'text/html'
)
email_msg
.
send
()
email_msg
.
send
()
except
Exception
:
# pylint: disable=broad-except
except
Exception
:
# pylint: disable=broad-except
...
...
course_discovery/apps/publisher/tests/test_emails.py
View file @
0c502bdb
# pylint: disable=no-member
# pylint: disable=no-member
import
mock
import
mock
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
from
django.contrib.sites.models
import
Site
from
django.core
import
mail
from
django.core
import
mail
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
...
@@ -65,8 +64,7 @@ class StudioInstanceCreatedEmailTests(TestCase):
...
@@ -65,8 +64,7 @@ class StudioInstanceCreatedEmailTests(TestCase):
def
assert_email_sent
(
self
,
object_path
,
subject
,
expected_body
):
def
assert_email_sent
(
self
,
object_path
,
subject
,
expected_body
):
""" Assert email data"""
""" Assert email data"""
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
([
settings
.
PUBLISHER_FROM_EMAIL
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
([
self
.
course_team
.
email
],
mail
.
outbox
[
0
]
.
to
)
self
.
assertEqual
([
self
.
user
.
email
,
self
.
course_team
.
email
],
mail
.
outbox
[
0
]
.
bcc
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
subject
)
self
.
assertEqual
(
str
(
mail
.
outbox
[
0
]
.
subject
),
subject
)
body
=
mail
.
outbox
[
0
]
.
body
.
strip
()
body
=
mail
.
outbox
[
0
]
.
body
.
strip
()
...
...
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