Merge pull request #9986 from mitocw/fix/jf/enroll-ccx-coaches
Enroll CCX coaches in the courses to which they're added
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user