Skip to content

Commit a7b3110

Browse files
committed
chore: address pr review
1 parent 696991e commit a7b3110

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

cms/djangoapps/contentstore/views/course.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,10 +844,26 @@ def _get_course_keys_from_platform_scope() -> set[CourseKey]:
844844
}
845845

846846

847-
def _get_course_keys_from_scopes(authz_scopes: list[ScopeData]):
847+
def _get_course_keys_from_scopes(authz_scopes: list[ScopeData]) -> set[CourseKey]:
848848
"""
849-
Convert a set of Authz scopes into specific course keys.
849+
Convert authorization scopes into a set of accessible course keys.
850+
851+
This function processes authorization scopes with the following precedence:
852+
1. Platform-wide access (PlatformCourseOverviewGlobData): Returns all courses
853+
2. Course-specific access (CourseOverviewData): Returns individual course keys
854+
3. Organization-wide access (OrgCourseOverviewGlobData): Returns all courses in specified orgs
855+
856+
Only courses with the authz course authoring toggle enabled are included.
857+
858+
Args:
859+
authz_scopes: List of authorization scope data objects from the authz system.
860+
861+
Returns:
862+
set[CourseKey]: Set of course keys the user has access to based on their scopes.
850863
"""
864+
if any(isinstance(access, PlatformCourseOverviewGlobData) for access in authz_scopes):
865+
return _get_course_keys_from_platform_scope()
866+
851867
course_keys = set()
852868
org_keys = set()
853869

@@ -857,14 +873,13 @@ def _get_course_keys_from_scopes(authz_scopes: list[ScopeData]):
857873
course_keys.add(access.course_key)
858874
elif isinstance(access, OrgCourseOverviewGlobData) and access.org:
859875
org_keys.add(access.org)
860-
elif isinstance(access, PlatformCourseOverviewGlobData):
861-
return _get_course_keys_from_platform_scope()
862876

863877
if org_keys:
864878
course_keys.update(
865879
key for key in _get_course_keys_for_org_scope(org_keys)
866880
if core_toggles.enable_authz_course_authoring(key)
867881
)
882+
868883
return course_keys
869884

870885

0 commit comments

Comments
 (0)