Skip to content

Commit f500a13

Browse files
committed
refactor: simplify user role assignment retrieval by using scoped api method
1 parent ca31466 commit f500a13

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

common/djangoapps/student/roles.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,10 @@ def authz_get_all_course_assignments_for_user(user: User) -> list[RoleAssignment
176176
Returns:
177177
list[RoleAssignmentData]: Role assignments whose scope is course-level or org-wide
178178
"""
179-
assignments = authz_api.get_user_role_assignments(user_external_key=user.username)
180-
return [
181-
assignment
182-
for assignment in assignments
183-
if isinstance(assignment.scope, CourseOverviewData | OrgCourseOverviewGlobData)
184-
]
179+
return authz_api.get_user_role_assignments_per_scope_type(
180+
user_external_key=user.username,
181+
scope_types=(CourseOverviewData, OrgCourseOverviewGlobData),
182+
)
185183

186184

187185
def _compat_roles_from_authz_assignment(

0 commit comments

Comments
 (0)