forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create Course Limited Staff role
This is an experimental approach to introduce a role which has all Course Staff permissions, except for the Studio access. Co-authored-by: 0x29a <[email protected]> (cherry picked from commit 3ccfe7c)
- Loading branch information
1 parent
05324a5
commit 6b01531
Showing
7 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
from common.djangoapps.student.roles import ( | ||
CourseCreatorRole, | ||
CourseInstructorRole, | ||
CourseLimitedStaffRole, | ||
CourseStaffRole, | ||
OrgContentCreatorRole | ||
) | ||
|
@@ -200,7 +201,7 @@ def test_no_staff_read_access(self): | |
|
||
class CourseGroupTest(TestCase): | ||
""" | ||
Tests for instructor and staff groups for a particular course. | ||
Tests for instructor, staff and limited staff groups for a particular course. | ||
""" | ||
|
||
def setUp(self): | ||
|
@@ -213,6 +214,9 @@ def setUp(self): | |
self.staff = UserFactory.create( | ||
username='teststaff', email='[email protected]', password='foo', | ||
) | ||
self.limited_staff = UserFactory.create( | ||
username='testlimitedstaff', email='[email protected]', password='foo', | ||
) | ||
self.course_key = CourseLocator('mitX', '101', 'test') | ||
|
||
def test_add_user_to_course_group(self): | ||
|
@@ -230,6 +234,14 @@ def test_add_user_to_course_group(self): | |
add_users(self.creator, CourseStaffRole(self.course_key), self.staff) | ||
assert user_has_role(self.staff, CourseStaffRole(self.course_key)) | ||
|
||
# Add another user to the limited staff role. | ||
assert not user_has_role(self.limited_staff, CourseLimitedStaffRole(self.course_key)) | ||
add_users(self.creator, CourseLimitedStaffRole(self.course_key), self.limited_staff) | ||
assert user_has_role(self.limited_staff, CourseLimitedStaffRole(self.course_key)) | ||
|
||
# Verify that limited staff inherits from staff. | ||
assert user_has_role(self.limited_staff, CourseStaffRole(self.course_key)) | ||
|
||
def test_add_user_to_course_group_permission_denied(self): | ||
""" | ||
Verifies PermissionDenied if caller of add_user_to_course_group is not instructor role. | ||
|
@@ -249,6 +261,12 @@ def test_remove_user_from_course_group(self): | |
add_users(self.creator, CourseStaffRole(self.course_key), self.staff) | ||
assert user_has_role(self.staff, CourseStaffRole(self.course_key)) | ||
|
||
add_users(self.creator, CourseLimitedStaffRole(self.course_key), self.limited_staff) | ||
assert user_has_role(self.limited_staff, CourseLimitedStaffRole(self.course_key)) | ||
|
||
remove_users(self.creator, CourseLimitedStaffRole(self.course_key), self.limited_staff) | ||
assert not user_has_role(self.limited_staff, CourseLimitedStaffRole(self.course_key)) | ||
|
||
remove_users(self.creator, CourseStaffRole(self.course_key), self.staff) | ||
assert not user_has_role(self.staff, CourseStaffRole(self.course_key)) | ||
|
||
|
@@ -267,6 +285,15 @@ def test_remove_user_from_course_group_permission_denied(self): | |
with pytest.raises(PermissionDenied): | ||
remove_users(self.staff, CourseStaffRole(self.course_key), another_staff) | ||
|
||
def test_no_limited_staff_read_or_write_access(self): | ||
""" | ||
Test that course limited staff have no read or write access. | ||
""" | ||
add_users(self.global_admin, CourseLimitedStaffRole(self.course_key), self.limited_staff) | ||
|
||
assert not has_studio_read_access(self.limited_staff, self.course_key) | ||
assert not has_studio_write_access(self.limited_staff, self.course_key) | ||
|
||
|
||
class CourseOrgGroupTest(TestCase): | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters