Skip to content

Commit 1fce6e9

Browse files
committed
squash!: Apply suggestions
1 parent 308b0ea commit 1fce6e9

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
@@ -1317,20 +1317,23 @@ class TestTeamMemberAssignmentsAPIView(ViewTestMixin):
13171317
lib:Org3:LIB3 → admin_3 (library_admin), regular_5 (library_admin), regular_6 (library_author),
13181318
regular_7 (library_contributor), regular_8 (library_user)
13191319
1320-
URL: /authz/v1/users/<username>/assignments
1320+
URL: /api/authz/v1/users/<username>/assignments/
13211321
Response fields per item: is_superadmin, role, org, scope, permission_count
13221322
13231323
Superadmin entry:
1324-
admin_1..3 are staff/superusers. Querying any of them adds one entry
1324+
admin_1..3 are staff/superusers. Querying any of them always adds one
13251325
SuperAdminAssignmentData entry: role="django.superuser" (or "django.staff"),
13261326
org="*", scope="*", permission_count=None, is_superadmin=True.
13271327
This entry is always included regardless of org/role filters, since those
13281328
filters are applied only to the role assignments, not to the superadmin entry.
13291329
13301330
Visibility via filter_allowed_assignments:
1331-
- Staff/superuser: sees all assignments for any user
1332-
- regular_1 (library_user in Org1:LIB1): sees only Org1:LIB1 assignments
1333-
- regular_9 (no assignments): sees nothing for any user
1331+
- Staff/superuser: sees all role assignments for any user, plus the superadmin
1332+
entry when the target is a superadmin.
1333+
- regular_1 (library_user in Org1:LIB1): sees only Org1:LIB1 role assignments,
1334+
plus the superadmin entry when the target is a superadmin.
1335+
- regular_9 (no assignments): sees no role assignments for any user, but still
1336+
sees the superadmin entry when the target is a superadmin.
13341337
"""
13351338

13361339
def setUp(self):

0 commit comments

Comments
 (0)