Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
GlobalStaff,
UserBasedRole,
OrgStaffRole,
eSHEInstructorRole,
TeachingAssistantRole,
strict_role_checking,
)
from common.djangoapps.util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
Expand Down Expand Up @@ -537,7 +539,9 @@ def filter_ccx(course_access):
with strict_role_checking():
staff_courses = UserBasedRole(request.user, CourseStaffRole.ROLE).courses_with_role()

all_courses = list(filter(filter_ccx, instructor_courses | staff_courses))
eshe_instructor_courses = UserBasedRole(request.user, eSHEInstructorRole.ROLE).courses_with_role()
ta_courses = UserBasedRole(request.user, TeachingAssistantRole.ROLE).courses_with_role()
all_courses = list(filter(filter_ccx, instructor_courses | staff_courses | eshe_instructor_courses | ta_courses))
courses_list = []
course_keys = {}

Expand Down
10 changes: 10 additions & 0 deletions common/djangoapps/student/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
OrgInstructorRole,
OrgLibraryUserRole,
OrgStaffRole,
eSHEInstructorRole,
TeachingAssistantRole,
strict_role_checking,
)

Expand Down Expand Up @@ -100,6 +102,14 @@ def get_user_permissions(user, course_key, org=None, service_variant=None):
return all_perms
if course_key and user_has_role(user, CourseInstructorRole(course_key)):
return all_perms

# Allow custom eSHE roles to access course detail in studio
# We have offered all permissions equivalent to Staff user
# This is to demonstrate how the custom roles can be elevated, NOT PRODUCTION READY
if course_key:
if eSHEInstructorRole(course_key).has_user(user) or TeachingAssistantRole(course_key).has_user(user):
return STUDIO_EDIT_ROLES | STUDIO_VIEW_USERS | STUDIO_EDIT_CONTENT | STUDIO_VIEW_CONTENT

# HACK: Limited Staff should not have studio read access. However, since many LMS views depend on the
# `has_course_author_access` check and `course_author_access_required` decorator, we have to allow write access
# by returning STUDIO_EDIT_CONTENT, if the request is made from LMS, until the permissions become more granular.
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/djangoapps/content/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rest_framework.request import Request

from common.djangoapps.student.role_helpers import get_course_roles
from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole
from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole, eSHEInstructorRole, TeachingAssistantRole
from openedx.core.djangoapps.content_libraries.api import get_libraries_for_user


Expand Down Expand Up @@ -48,7 +48,7 @@ def get_access_ids_for_request(request: Request, omit_orgs: list[str] = None) ->
role.course_id
for role in course_roles
if (
role.role in [CourseInstructorRole.ROLE, CourseStaffRole.ROLE]
role.role in [eSHEInstructorRole.ROLE, TeachingAssistantRole.ROLE, CourseInstructorRole.ROLE, CourseStaffRole.ROLE]
and role.org not in omit_orgs
)
])
Expand Down