Skip to content

Commit 82d43e0

Browse files
committed
chore: update deprecation warnings to include alternative methods and views
1 parent d8eb27c commit 82d43e0

2 files changed

Lines changed: 54 additions & 4 deletions

File tree

openedx/core/djangoapps/content_libraries/api/libraries.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ def get_library_team(library_key: LibraryLocatorV2) -> list[ContentLibraryPermis
496496
Get the list of users/groups granted permission to use this library.
497497
"""
498498
warnings.warn(
499-
"get_library_team is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.",
499+
"get_library_team is deprecated. "
500+
"Use get_all_user_role_assignments_in_scope from the openedx-authz API instead. "
501+
"See https://github.com/openedx/openedx-platform/issues/37409.",
500502
DeprecationWarning,
501503
stacklevel=2,
502504
)
@@ -514,7 +516,9 @@ def get_library_user_permissions(library_key: LibraryLocatorV2, user: UserType)
514516
permissions have been granted.
515517
"""
516518
warnings.warn(
517-
"get_library_user_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.",
519+
"get_library_user_permissions is deprecated. "
520+
"Use get_user_role_assignments_in_scope from the openedx-authz API instead. "
521+
"See https://github.com/openedx/openedx-platform/issues/37409.",
518522
DeprecationWarning,
519523
stacklevel=2,
520524
)
@@ -539,7 +543,9 @@ def set_library_user_permissions(library_key: LibraryLocatorV2, user: UserType,
539543
access_level should be one of the AccessLevel values defined above.
540544
"""
541545
warnings.warn(
542-
"set_library_user_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.",
546+
"set_library_user_permissions is deprecated. "
547+
"Use assign_library_role_to_user instead. "
548+
"See https://github.com/openedx/openedx-platform/issues/37409.",
543549
DeprecationWarning,
544550
stacklevel=2,
545551
)
@@ -593,7 +599,9 @@ def set_library_group_permissions(library_key: LibraryLocatorV2, group, access_l
593599
access_level should be one of the AccessLevel values defined above.
594600
"""
595601
warnings.warn(
596-
"set_library_group_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.",
602+
"set_library_group_permissions is deprecated. "
603+
"Use assign_library_role_to_user instead. "
604+
"See https://github.com/openedx/openedx-platform/issues/37409.",
597605
DeprecationWarning,
598606
stacklevel=2,
599607
)

openedx/core/djangoapps/content_libraries/rest_api/libraries.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ def post(self, request, lib_key_str):
342342
Add a user to this content library via email, with permissions specified in the
343343
request body.
344344
"""
345+
warnings.warn(
346+
"LibraryTeamView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
347+
DeprecationWarning,
348+
stacklevel=2,
349+
)
350+
345351
key = LibraryLocatorV2.from_string(lib_key_str)
346352
api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM)
347353
serializer = ContentLibraryAddPermissionByEmailSerializer(data=request.data)
@@ -369,6 +375,12 @@ def get(self, request, lib_key_str):
369375
Get the list of users and groups who have permissions to view and edit
370376
this library.
371377
"""
378+
warnings.warn(
379+
"LibraryTeamView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
380+
DeprecationWarning,
381+
stacklevel=2,
382+
)
383+
372384
key = LibraryLocatorV2.from_string(lib_key_str)
373385
api.require_permission_for_library_key(key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY_TEAM)
374386
team = api.get_library_team(key)
@@ -390,6 +402,12 @@ def put(self, request, lib_key_str, username):
390402
Add a user to this content library, with permissions specified in the
391403
request body.
392404
"""
405+
warnings.warn(
406+
"LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
407+
DeprecationWarning,
408+
stacklevel=2,
409+
)
410+
393411
key = LibraryLocatorV2.from_string(lib_key_str)
394412
api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM)
395413
serializer = ContentLibraryPermissionLevelSerializer(data=request.data)
@@ -407,6 +425,12 @@ def get(self, request, lib_key_str, username):
407425
"""
408426
Gets the current permissions settings for a particular user.
409427
"""
428+
warnings.warn(
429+
"LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
430+
DeprecationWarning,
431+
stacklevel=2,
432+
)
433+
410434
key = LibraryLocatorV2.from_string(lib_key_str)
411435
api.require_permission_for_library_key(key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY_TEAM)
412436
user = get_object_or_404(User, username=username)
@@ -421,6 +445,12 @@ def delete(self, request, lib_key_str, username):
421445
Remove the specified user's permission to access or edit this content
422446
library.
423447
"""
448+
warnings.warn(
449+
"LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
450+
DeprecationWarning,
451+
stacklevel=2,
452+
)
453+
424454
key = LibraryLocatorV2.from_string(lib_key_str)
425455
api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM)
426456
user = get_object_or_404(User, username=username)
@@ -445,6 +475,12 @@ def put(self, request, lib_key_str, group_name):
445475
Add a group to this content library, with permissions specified in the
446476
request body.
447477
"""
478+
warnings.warn(
479+
"LibraryTeamGroupView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
480+
DeprecationWarning,
481+
stacklevel=2,
482+
)
483+
448484
key = LibraryLocatorV2.from_string(lib_key_str)
449485
api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM)
450486
serializer = ContentLibraryPermissionLevelSerializer(data=request.data)
@@ -459,6 +495,12 @@ def delete(self, request, lib_key_str, username):
459495
Remove the specified user's permission to access or edit this content
460496
library.
461497
"""
498+
warnings.warn(
499+
"LibraryTeamGroupView is deprecated. Use RoleUserAPIView from openedx-authz instead.",
500+
DeprecationWarning,
501+
stacklevel=2,
502+
)
503+
462504
key = LibraryLocatorV2.from_string(lib_key_str)
463505
api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM)
464506
group = get_object_or_404(Group, username=username)

0 commit comments

Comments
 (0)