-
Notifications
You must be signed in to change notification settings - Fork 4.3k
chore: deprecate content libraries authorization permissions, apis, rest apis and models #38052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feanil
merged 4 commits into
openedx:master
from
eduNEXT:bav/depr-content-libraries-permissions
Mar 2, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d7e6b33
chore: deprecate content library authorization rest apis and models
BryanttV c6f5bcf
refactor: remove ContentLibraryPermissionInline from admin interface
BryanttV b6a3b23
chore: deprecate legacy content library permissions and APIs.
BryanttV fee0a1a
chore: update deprecation warnings to include alternative methods and…
BryanttV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ | |
| import itertools | ||
| import json | ||
| import logging | ||
| import warnings | ||
|
|
||
| import edx_api_doc_tools as apidocs | ||
| from django.conf import settings | ||
|
|
@@ -136,6 +137,15 @@ | |
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| warnings.warn( | ||
| ( | ||
| "Content library team authorization REST APIs are deprecated. " | ||
| "See https://github.com/openedx/openedx-platform/issues/37409." | ||
| ), | ||
| DeprecationWarning | ||
| ) | ||
|
Comment on lines
+140
to
+146
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment -- this warning should only fire when the old REST APIs are used, currently it will be raised for everybody, since everybody's site uses the Libraries REST API. |
||
|
|
||
|
|
||
| class LibraryApiPaginationDocs: | ||
| """ | ||
| API docs for query params related to paginating ContentLibraryMetadata objects. | ||
|
|
@@ -323,13 +333,21 @@ class LibraryTeamView(APIView): | |
|
|
||
| Note also the 'allow_public_' settings which can be edited by PATCHing the | ||
| library itself (LibraryDetailsView.patch). | ||
|
|
||
| Deprecated https://github.com/openedx/openedx-platform/issues/37409 | ||
| """ | ||
| @convert_exceptions | ||
| def post(self, request, lib_key_str): | ||
| """ | ||
| 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) | ||
|
|
@@ -357,6 +375,12 @@ def get(self, request, lib_key_str): | |
| 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) | ||
|
|
@@ -369,13 +393,21 @@ class LibraryTeamUserView(APIView): | |
| """ | ||
| View to add/remove/edit an individual user's permissions for a content | ||
| library. | ||
|
|
||
| Deprecated https://github.com/openedx/openedx-platform/issues/37409 | ||
| """ | ||
| @convert_exceptions | ||
| def put(self, request, lib_key_str, username): | ||
| """ | ||
| 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) | ||
|
|
@@ -393,6 +425,12 @@ def get(self, request, lib_key_str, username): | |
| """ | ||
| 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) | ||
|
|
@@ -407,6 +445,12 @@ def delete(self, request, lib_key_str, username): | |
| 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) | ||
|
|
@@ -422,13 +466,21 @@ def delete(self, request, lib_key_str, username): | |
| class LibraryTeamGroupView(APIView): | ||
| """ | ||
| View to add/remove/edit a group's permissions for a content library. | ||
|
|
||
| Deprecated https://github.com/openedx/openedx-platform/issues/37409 | ||
| """ | ||
| @convert_exceptions | ||
| def put(self, request, lib_key_str, group_name): | ||
| """ | ||
| 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) | ||
|
|
@@ -443,6 +495,12 @@ def delete(self, request, lib_key_str, username): | |
| 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) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BryanttV This warning will be raised whenever models.py is imported, even if the importer isn't using ContentLibraryPermission model. It should be possible for developers to resolve a deprecation warning, but the only way to resolve this one would be to stop using ContentLibraries entirely. Could you move this into the ContentLibraryPermission model?