Commit 86865d5d by Waheed Ahmed

Remove CT from reviewed email when PC approves course-run.

ECOM-7767
parent 917a3152
......@@ -671,7 +671,7 @@ class ChangeCourseRunStateViewTests(TestCase):
def test_mark_as_reviewed(self):
"""
Verify that user can change course-run workflow state and owner role will be changed to `Publisher`.
Verify that course team can approve the changes and owner role will be changed to `Publisher`.
"""
self.run_state.name = CourseRunStateChoices.Review
self.run_state.owner_role = PublisherUserRole.CourseTeam
......@@ -697,6 +697,35 @@ class ChangeCourseRunStateViewTests(TestCase):
self.assertEqual(len(mail.outbox), 2)
def test_mark_as_reviewed_by_pc(self):
"""
Verify that project coordinator can approve the changes and email not sent to course team.
"""
self.run_state.name = CourseRunStateChoices.Review
self.run_state.owner_role = PublisherUserRole.ProjectCoordinator
self.run_state.save()
self._assign_role(self.course_run.course, PublisherUserRole.ProjectCoordinator, self.user)
self._assign_role(self.course_run.course, PublisherUserRole.CourseTeam, UserFactory())
self._assign_role(self.course_run.course, PublisherUserRole.Publisher, UserFactory())
response = self.client.patch(
self.change_state_url,
data=json.dumps({'name': CourseStateChoices.Approved}),
content_type=JSON_CONTENT_TYPE
)
self.assertEqual(response.status_code, 200)
self.run_state = CourseRunState.objects.get(course_run=self.course_run)
self.assertEqual(self.run_state.name, CourseRunStateChoices.Approved)
self.assertEqual(self.run_state.owner_role, PublisherUserRole.Publisher)
self.assertEqual(len(mail.outbox), 1)
self.assertNotIn(self.course_run.course.course_team_admin.email, mail.outbox[0].to)
def test_preview_accepted(self):
"""
Verify that user can accept preview for course run and owner role will be changed to `Publisher`.
......
......@@ -271,22 +271,22 @@ def send_email_for_mark_as_reviewed_course_run(course_run, user):
)
try:
page_path = reverse('publisher:publisher_course_run_detail', kwargs={'pk': course_run.id})
recipient_user = course.project_coordinator
user_role = course.course_user_roles.get(user=user)
if user_role.role == PublisherUserRole.ProjectCoordinator:
recipient_user = course.course_team_admin
# Send this email only to PC if approving person is course team member
if user_role.role == PublisherUserRole.CourseTeam:
page_path = reverse('publisher:publisher_course_run_detail', kwargs={'pk': course_run.id})
recipient_user = course.project_coordinator
context = {
'course_name': course.title,
'run_number': course_key.run,
'sender_team': 'course team' if user_role.role == PublisherUserRole.CourseTeam else 'project coordinators',
'page_url': 'https://{host}{path}'.format(
host=Site.objects.get_current().domain.strip('/'), path=page_path
)
}
context = {
'course_name': course.title,
'run_number': course_key.run,
'sender_team': 'course team',
'page_url': 'https://{host}{path}'.format(
host=Site.objects.get_current().domain.strip('/'), path=page_path
)
}
send_course_workflow_email(course, user, subject, txt_template, html_template, context, recipient_user)
send_course_workflow_email(course, user, subject, txt_template, html_template, context, recipient_user)
except Exception: # pylint: disable=broad-except
logger.exception('Failed to send email notifications for mark as reviewed of course-run %s', course_run.id)
......
......@@ -303,13 +303,13 @@ class CourseRunMarkAsReviewedEmailTests(TestCase):
toggle_switch('enable_publisher_email_notifications', True)
def test_email_sent_by_marketing_reviewer(self):
""" Verify that email works successfully for marketing user."""
def test_email_not_sent_by_project_coordinator(self):
""" Verify that no email is sent if approving person is project coordinator. """
factories.CourseUserRoleFactory(
course=self.course, role=PublisherUserRole.ProjectCoordinator, user=self.user
)
emails.send_email_for_mark_as_reviewed_course_run(self.course_run_state.course_run, self.user)
self.assert_email_sent(self.user_2)
self.assertEqual(len(mail.outbox), 0)
def test_email_sent_by_course_team(self):
""" Verify that email works successfully for course team user."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment