Skip to content

Commit eb87e0a

Browse files
committed
Revert "fix: CourseLimitedStaffRole should not be able to access studio."
This reverts commit 4eb92fd.
1 parent 9d756f7 commit eb87e0a

4 files changed

Lines changed: 3 additions & 70 deletions

File tree

cms/djangoapps/contentstore/tests/test_course_listing.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
get_courses_accessible_to_user
2424
)
2525
from common.djangoapps.course_action_state.models import CourseRerunState
26-
from common.djangoapps.student.models.user import CourseAccessRole
2726
from common.djangoapps.student.roles import (
2827
CourseInstructorRole,
29-
CourseLimitedStaffRole,
3028
CourseStaffRole,
3129
GlobalStaff,
3230
OrgInstructorRole,
@@ -201,48 +199,6 @@ def test_staff_course_listing(self):
201199
with check_mongo_calls(2):
202200
list(_accessible_courses_summary_iter(self.request))
203201

204-
def test_course_limited_staff_course_listing(self):
205-
# Setup a new course
206-
course_location = self.store.make_course_key('Org', 'CreatedCourse', 'Run')
207-
CourseFactory.create(
208-
org=course_location.org,
209-
number=course_location.course,
210-
run=course_location.run
211-
)
212-
course = CourseOverviewFactory.create(id=course_location, org=course_location.org)
213-
214-
# Add the user as a course_limited_staff on the course
215-
CourseLimitedStaffRole(course.id).add_users(self.user)
216-
self.assertTrue(CourseLimitedStaffRole(course.id).has_user(self.user))
217-
218-
# Fetch accessible courses list & verify their count
219-
courses_list_by_staff, __ = get_courses_accessible_to_user(self.request)
220-
221-
# Limited Course Staff should not be able to list courses in Studio
222-
assert len(list(courses_list_by_staff)) == 0
223-
224-
def test_org_limited_staff_course_listing(self):
225-
226-
# Setup a new course
227-
course_location = self.store.make_course_key('Org', 'CreatedCourse', 'Run')
228-
CourseFactory.create(
229-
org=course_location.org,
230-
number=course_location.course,
231-
run=course_location.run
232-
)
233-
course = CourseOverviewFactory.create(id=course_location, org=course_location.org)
234-
235-
# Add a user as course_limited_staff on the org
236-
# This is not possible using the course roles classes but is possible via Django admin so we
237-
# insert a row into the model directly to test that scenario.
238-
CourseAccessRole.objects.create(user=self.user, org=course_location.org, role=CourseLimitedStaffRole.ROLE)
239-
240-
# Fetch accessible courses list & verify their count
241-
courses_list_by_staff, __ = get_courses_accessible_to_user(self.request)
242-
243-
# Limited Course Staff should not be able to list courses in Studio
244-
assert len(list(courses_list_by_staff)) == 0
245-
246202
def test_get_course_list_with_invalid_course_location(self):
247203
"""
248204
Test getting courses with invalid course location (course deleted from modulestore).

cms/djangoapps/contentstore/views/course.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
GlobalStaff,
5555
UserBasedRole,
5656
OrgStaffRole,
57-
strict_role_checking,
5857
)
5958
from common.djangoapps.util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
6059
from common.djangoapps.util.string_utils import _has_non_ascii_characters
@@ -553,9 +552,7 @@ def filter_ccx(course_access):
553552
return not isinstance(course_access.course_id, CCXLocator)
554553

555554
instructor_courses = UserBasedRole(request.user, CourseInstructorRole.ROLE).courses_with_role()
556-
with strict_role_checking():
557-
staff_courses = UserBasedRole(request.user, CourseStaffRole.ROLE).courses_with_role()
558-
555+
staff_courses = UserBasedRole(request.user, CourseStaffRole.ROLE).courses_with_role()
559556
all_courses = list(filter(filter_ccx, instructor_courses | staff_courses))
560557
courses_list = []
561558
course_keys = {}

common/djangoapps/student/auth.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
OrgInstructorRole,
2525
OrgLibraryUserRole,
2626
OrgStaffRole,
27-
strict_role_checking,
2827
)
2928

3029
# Studio permissions:
@@ -110,9 +109,8 @@ def get_user_permissions(user, course_key, org=None, service_variant=None):
110109
return STUDIO_NO_PERMISSIONS
111110

112111
# Staff have all permissions except EDIT_ROLES:
113-
with strict_role_checking():
114-
if OrgStaffRole(org=org).has_user(user) or (course_key and user_has_role(user, CourseStaffRole(course_key))):
115-
return STUDIO_VIEW_USERS | STUDIO_EDIT_CONTENT | STUDIO_VIEW_CONTENT
112+
if OrgStaffRole(org=org).has_user(user) or (course_key and user_has_role(user, CourseStaffRole(course_key))):
113+
return STUDIO_VIEW_USERS | STUDIO_EDIT_CONTENT | STUDIO_VIEW_CONTENT
116114

117115
# Otherwise, for libraries, users can view only:
118116
if course_key and isinstance(course_key, LibraryLocator):

common/djangoapps/student/tests/test_authz.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from django.test import TestCase, override_settings
1212
from opaque_keys.edx.locator import CourseLocator
1313

14-
from common.djangoapps.student.models.user import CourseAccessRole
1514
from common.djangoapps.student.auth import (
1615
add_users,
1716
has_studio_read_access,
@@ -306,23 +305,6 @@ def test_limited_staff_no_studio_access_cms(self):
306305
assert not has_studio_read_access(self.limited_staff, self.course_key)
307306
assert not has_studio_write_access(self.limited_staff, self.course_key)
308307

309-
@override_settings(SERVICE_VARIANT='cms')
310-
def test_limited_org_staff_no_studio_access_cms(self):
311-
"""
312-
Verifies that course limited staff have no read and no write access when SERVICE_VARIANT is not 'lms'.
313-
"""
314-
# Add a user as course_limited_staff on the org
315-
# This is not possible using the course roles classes but is possible via Django admin so we
316-
# insert a row into the model directly to test that scenario.
317-
CourseAccessRole.objects.create(
318-
user=self.limited_staff,
319-
org=self.course_key.org,
320-
role=CourseLimitedStaffRole.ROLE,
321-
)
322-
323-
assert not has_studio_read_access(self.limited_staff, self.course_key)
324-
assert not has_studio_write_access(self.limited_staff, self.course_key)
325-
326308

327309
class CourseOrgGroupTest(TestCase):
328310
"""

0 commit comments

Comments
 (0)