From c9fc35d2535a4a2c02e4f8bb01094f08f9a0d3cb Mon Sep 17 00:00:00 2001 From: Jamie Folsom Date: Tue, 29 Sep 2015 15:52:32 -0400 Subject: [PATCH] Enroll CCX coaches in courses as they're added as coaches. Remove log statements. Add test for CCX coach access addition. Email CCX coaches when they're enrolled. Remove ccx_coach from list of roles which can perform access maintenance. Remove unused variables. Remove unused import (unenroll_email) Fix long line in instructor/access.py. Address long line formatting issue. --- lms/djangoapps/instructor/access.py | 13 +++++++++++++ lms/djangoapps/instructor/tests/test_access.py | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/instructor/access.py b/lms/djangoapps/instructor/access.py index 80678193fe..440f2b8d38 100644 --- a/lms/djangoapps/instructor/access.py +++ b/lms/djangoapps/instructor/access.py @@ -19,6 +19,10 @@ from student.roles import ( CourseStaffRole, ) +from instructor.enrollment import ( + enroll_email, + get_email_params, +) log = logging.getLogger(__name__) @@ -75,6 +79,15 @@ def _change_access(course, user, level, action): raise ValueError("unrecognized level '{}'".format(level)) if action == 'allow': + if level == 'ccx_coach': + email_params = get_email_params(course, True) + enroll_email( + course_id=course.id, + student_email=user.email, + auto_enroll=True, + email_students=True, + email_params=email_params, + ) role.add_users(user) elif action == 'revoke': role.remove_users(user) diff --git a/lms/djangoapps/instructor/tests/test_access.py b/lms/djangoapps/instructor/tests/test_access.py index f66d3957a0..3ee1a427d1 100644 --- a/lms/djangoapps/instructor/tests/test_access.py +++ b/lms/djangoapps/instructor/tests/test_access.py @@ -8,7 +8,7 @@ from student.tests.factories import UserFactory from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from student.roles import CourseBetaTesterRole, CourseStaffRole +from student.roles import CourseBetaTesterRole, CourseStaffRole, CourseCcxCoachRole from django_comment_common.models import (Role, FORUM_ROLE_MODERATOR) @@ -68,6 +68,11 @@ class TestInstructorAccessAllow(SharedModuleStoreTestCase): allow_access(self.course, user, 'staff') self.assertTrue(CourseStaffRole(self.course.id).has_user(user)) + def test_allow_ccx_coach(self): + user = UserFactory() + allow_access(self.course, user, 'ccx_coach') + self.assertTrue(CourseCcxCoachRole(self.course.id).has_user(user)) + def test_allow_beta(self): """ Test allow beta against list beta. """ user = UserFactory()