Commit c9fc35d2 by Jamie Folsom Committed by Jamie Folsom

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.
parent c67bcaef
...@@ -19,6 +19,10 @@ from student.roles import ( ...@@ -19,6 +19,10 @@ from student.roles import (
CourseStaffRole, CourseStaffRole,
) )
from instructor.enrollment import (
enroll_email,
get_email_params,
)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -75,6 +79,15 @@ def _change_access(course, user, level, action): ...@@ -75,6 +79,15 @@ def _change_access(course, user, level, action):
raise ValueError("unrecognized level '{}'".format(level)) raise ValueError("unrecognized level '{}'".format(level))
if action == 'allow': 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) role.add_users(user)
elif action == 'revoke': elif action == 'revoke':
role.remove_users(user) role.remove_users(user)
......
...@@ -8,7 +8,7 @@ from student.tests.factories import UserFactory ...@@ -8,7 +8,7 @@ from student.tests.factories import UserFactory
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase 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, from django_comment_common.models import (Role,
FORUM_ROLE_MODERATOR) FORUM_ROLE_MODERATOR)
...@@ -68,6 +68,11 @@ class TestInstructorAccessAllow(SharedModuleStoreTestCase): ...@@ -68,6 +68,11 @@ class TestInstructorAccessAllow(SharedModuleStoreTestCase):
allow_access(self.course, user, 'staff') allow_access(self.course, user, 'staff')
self.assertTrue(CourseStaffRole(self.course.id).has_user(user)) 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): def test_allow_beta(self):
""" Test allow beta against list beta. """ """ Test allow beta against list beta. """
user = UserFactory() user = UserFactory()
......
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