File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -556,20 +556,21 @@ def unassign_subject_from_all_roles(subject: SubjectData) -> bool:
556556 return enforcer .remove_filtered_grouping_policy (GroupingPolicyIndex .SUBJECT .value , subject .namespaced_key )
557557
558558
559- def get_all_role_assignments_per_scope_type (scope_type : type [ScopeData ]) -> list [RoleAssignmentData ]:
560- """Get all role assignments for a specific scope type .
559+ def get_all_role_assignments_per_scope_type (scope_types : list [ type [ScopeData ] ]) -> list [RoleAssignmentData ]:
560+ """Get all role assignments matching any of the given scope types .
561561
562562 Loads all grouping policies from the enforcer and filters in Python. Casbin policies
563563 store full scope keys (e.g., 'course-v1^course-v1:Org+Course+Run'), so there is no
564564 way to query by scope type directly so the filtering must happen here.
565565
566566 Args:
567- scope_type: A ScopeData subclass (not an instance) used to match by NAMESPACE.
567+ scope_types: A list of ScopeData subclasses (not instances). Assignments matching
568+ any of the given types are returned.
568569
569570 Returns:
570- list[RoleAssignmentData]: All assignments whose scope matches the given scope type .
571+ list[RoleAssignmentData]: All assignments whose scope is an instance of any of the given scope types .
571572 """
572573 return [
573574 role_assignment for role_assignment in get_role_assignments ()
574- if role_assignment .scope . NAMESPACE == scope_type . NAMESPACE
575+ if isinstance ( role_assignment .scope , tuple ( scope_types ))
575576 ]
Original file line number Diff line number Diff line change @@ -319,11 +319,9 @@ def migrate_authz_to_legacy_course_roles(
319319 """
320320 _validate_migration_input (course_id_list , org_id )
321321
322- # CourseOverviewData and OrgCourseOverviewGlobData share the same NAMESPACE ("course-v1"),
323- # and get_all_role_assignments_per_scope_type matches by NAMESPACE. Passing CourseOverviewData
324- # therefore captures both course-level and org-level glob assignments. The exact scope type
325- # is narrowed per-assignment via isinstance checks in the loop below.
326- role_assignments = get_all_role_assignments_per_scope_type (scope_type = CourseOverviewData )
322+ role_assignments = get_all_role_assignments_per_scope_type (
323+ scope_types = [CourseOverviewData , OrgCourseOverviewGlobData ]
324+ )
327325
328326 # Two cases here:
329327 # 1. org_id provided: filter by org — includes org-level glob and course-level scopes for that org.
You can’t perform that action at this time.
0 commit comments