From 71ecea98cdf391bd59e5f40b72767ec5e98633c3 Mon Sep 17 00:00:00 2001 From: Bryann Valderrama Date: Fri, 27 Feb 2026 16:24:28 -0500 Subject: [PATCH] chore: update deprecation warnings to include alternative methods and views --- .../content_libraries/api/libraries.py | 16 +++++-- .../content_libraries/rest_api/libraries.py | 42 +++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/openedx/core/djangoapps/content_libraries/api/libraries.py b/openedx/core/djangoapps/content_libraries/api/libraries.py index 47a6006614..fce2ce5ec4 100644 --- a/openedx/core/djangoapps/content_libraries/api/libraries.py +++ b/openedx/core/djangoapps/content_libraries/api/libraries.py @@ -496,7 +496,9 @@ def get_library_team(library_key: LibraryLocatorV2) -> list[ContentLibraryPermis Get the list of users/groups granted permission to use this library. """ warnings.warn( - "get_library_team is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.", + "get_library_team is deprecated. " + "Use get_all_user_role_assignments_in_scope from the openedx-authz API instead. " + "See https://github.com/openedx/openedx-platform/issues/37409.", DeprecationWarning, stacklevel=2, ) @@ -514,7 +516,9 @@ def get_library_user_permissions(library_key: LibraryLocatorV2, user: UserType) permissions have been granted. """ warnings.warn( - "get_library_user_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.", + "get_library_user_permissions is deprecated. " + "Use get_user_role_assignments_in_scope from the openedx-authz API instead. " + "See https://github.com/openedx/openedx-platform/issues/37409.", DeprecationWarning, stacklevel=2, ) @@ -539,7 +543,9 @@ def set_library_user_permissions(library_key: LibraryLocatorV2, user: UserType, access_level should be one of the AccessLevel values defined above. """ warnings.warn( - "set_library_user_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.", + "set_library_user_permissions is deprecated. " + "Use assign_library_role_to_user instead. " + "See https://github.com/openedx/openedx-platform/issues/37409.", DeprecationWarning, stacklevel=2, ) @@ -593,7 +599,9 @@ def set_library_group_permissions(library_key: LibraryLocatorV2, group, access_l access_level should be one of the AccessLevel values defined above. """ warnings.warn( - "set_library_group_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.", + "set_library_group_permissions is deprecated. " + "Use assign_library_role_to_user instead. " + "See https://github.com/openedx/openedx-platform/issues/37409.", DeprecationWarning, stacklevel=2, ) diff --git a/openedx/core/djangoapps/content_libraries/rest_api/libraries.py b/openedx/core/djangoapps/content_libraries/rest_api/libraries.py index 0485c7c8ed..3c531d6297 100644 --- a/openedx/core/djangoapps/content_libraries/rest_api/libraries.py +++ b/openedx/core/djangoapps/content_libraries/rest_api/libraries.py @@ -342,6 +342,12 @@ class LibraryTeamView(APIView): Add a user to this content library via email, with permissions specified in the request body. """ + warnings.warn( + "LibraryTeamView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM) serializer = ContentLibraryAddPermissionByEmailSerializer(data=request.data) @@ -369,6 +375,12 @@ class LibraryTeamView(APIView): Get the list of users and groups who have permissions to view and edit this library. """ + warnings.warn( + "LibraryTeamView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY_TEAM) team = api.get_library_team(key) @@ -390,6 +402,12 @@ class LibraryTeamUserView(APIView): Add a user to this content library, with permissions specified in the request body. """ + warnings.warn( + "LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM) serializer = ContentLibraryPermissionLevelSerializer(data=request.data) @@ -407,6 +425,12 @@ class LibraryTeamUserView(APIView): """ Gets the current permissions settings for a particular user. """ + warnings.warn( + "LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY_TEAM) user = get_object_or_404(User, username=username) @@ -421,6 +445,12 @@ class LibraryTeamUserView(APIView): Remove the specified user's permission to access or edit this content library. """ + warnings.warn( + "LibraryTeamUserView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM) user = get_object_or_404(User, username=username) @@ -445,6 +475,12 @@ class LibraryTeamGroupView(APIView): Add a group to this content library, with permissions specified in the request body. """ + warnings.warn( + "LibraryTeamGroupView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM) serializer = ContentLibraryPermissionLevelSerializer(data=request.data) @@ -459,6 +495,12 @@ class LibraryTeamGroupView(APIView): Remove the specified user's permission to access or edit this content library. """ + warnings.warn( + "LibraryTeamGroupView is deprecated. Use RoleUserAPIView from openedx-authz instead.", + DeprecationWarning, + stacklevel=2, + ) + key = LibraryLocatorV2.from_string(lib_key_str) api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY_TEAM) group = get_object_or_404(Group, username=username)