Skip to content

Commit eab7269

Browse files
committed
squash!: Apply suggestions
1 parent aaa9f28 commit eab7269

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

openedx_authz/rest_api/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from openedx_authz.api.data import (
44
GLOBAL_SCOPE_WILDCARD,
5-
RoleAssignmentData,
65
ScopeData,
76
)
87
from openedx_authz.rest_api.data import AssignmentSortField, SearchField, SortField, SortOrder
@@ -97,15 +96,15 @@ def filter_users(users: list[dict], search: str | None, roles: list[str] | None)
9796

9897

9998
def sort_assignments(
100-
assignments: list[RoleAssignmentData],
99+
assignments: list[dict],
101100
sort_by: AssignmentSortField = AssignmentSortField.ROLE,
102101
order: SortOrder = SortOrder.ASC,
103-
) -> list[RoleAssignmentData]:
102+
) -> list[dict]:
104103
"""
105104
Sort role assignments by a given field and order.
106105
107106
Args:
108-
assignments (list[RoleAssignmentData]): The assignments to sort.
107+
assignments (list[dict]): The assignments to sort.
109108
sort_by (SortField, optional): The field to sort by. Defaults to AssignmentSortField.ROLE.
110109
order (SortOrder, optional): The order to sort by. Defaults to SortOrder.ASC.
111110
@@ -114,7 +113,7 @@ def sort_assignments(
114113
ValueError: If the sort order is invalid.
115114
116115
Returns:
117-
list[RoleAssignmentData]: The sorted assignments.
116+
list[dict]: The sorted assignments.
118117
"""
119118
if sort_by not in AssignmentSortField.values():
120119
raise ValueError(f"Invalid field: '{sort_by}'. Must be one of {AssignmentSortField.values()}")

openedx_authz/tests/rest_api/test_views.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,20 +1318,23 @@ class TestTeamMemberAssignmentsAPIView(ViewTestMixin):
13181318
lib:Org3:LIB3 → admin_3 (library_admin), regular_5 (library_admin), regular_6 (library_author),
13191319
regular_7 (library_contributor), regular_8 (library_user)
13201320
1321-
URL: /authz/v1/users/<username>/assignments
1321+
URL: /api/authz/v1/users/<username>/assignments/
13221322
Response fields per item: is_superadmin, role, org, scope, permission_count
13231323
13241324
Superadmin entry:
1325-
admin_1..3 are staff/superusers. Querying any of them adds one entry
1325+
admin_1..3 are staff/superusers. Querying any of them always adds one
13261326
SuperAdminAssignmentData entry: role="django.superuser" (or "django.staff"),
13271327
org="*", scope="*", permission_count=None, is_superadmin=True.
13281328
This entry is always included regardless of org/role filters, since those
13291329
filters are applied only to the role assignments, not to the superadmin entry.
13301330
13311331
Visibility via filter_allowed_assignments:
1332-
- Staff/superuser: sees all assignments for any user
1333-
- regular_1 (library_user in Org1:LIB1): sees only Org1:LIB1 assignments
1334-
- regular_9 (no assignments): sees nothing for any user
1332+
- Staff/superuser: sees all role assignments for any user, plus the superadmin
1333+
entry when the target is a superadmin.
1334+
- regular_1 (library_user in Org1:LIB1): sees only Org1:LIB1 role assignments,
1335+
plus the superadmin entry when the target is a superadmin.
1336+
- regular_9 (no assignments): sees no role assignments for any user, but still
1337+
sees the superadmin entry when the target is a superadmin.
13351338
"""
13361339

13371340
def setUp(self):

0 commit comments

Comments
 (0)