chore: deprecate legacy content library permissions and APIs.

This commit is contained in:
Bryann Valderrama
2026-02-25 16:40:34 -05:00
committed by Feanil Patel
parent d05f39c9a8
commit de2c47c1c3
3 changed files with 32 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ could be promoted to the core XBlock API and made generic.
from __future__ import annotations
import logging
import warnings
from dataclasses import dataclass
from dataclasses import field as dataclass_field
from datetime import datetime
@@ -494,6 +495,12 @@ 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.",
DeprecationWarning,
stacklevel=2,
)
ref = ContentLibrary.objects.get_by_key(library_key)
return [
ContentLibraryPermissionEntry(user=entry.user, group=entry.group, access_level=entry.access_level)
@@ -506,6 +513,12 @@ def get_library_user_permissions(library_key: LibraryLocatorV2, user: UserType)
Fetch the specified user's access information. Will return None if no
permissions have been granted.
"""
warnings.warn(
"get_library_user_permissions is deprecated. See https://github.com/openedx/openedx-platform/issues/37409.",
DeprecationWarning,
stacklevel=2,
)
if isinstance(user, AnonymousUser):
return None # Mostly here for the type checker
ref = ContentLibrary.objects.get_by_key(library_key)
@@ -525,6 +538,12 @@ 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.",
DeprecationWarning,
stacklevel=2,
)
if isinstance(user, AnonymousUser):
raise TypeError("Invalid user type") # Mostly here for the type checker
ref = ContentLibrary.objects.get_by_key(library_key)
@@ -573,6 +592,12 @@ 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.",
DeprecationWarning,
stacklevel=2,
)
ref = ContentLibrary.objects.get_by_key(library_key)
if access_level is None:

View File

@@ -1,5 +1,8 @@
"""
Public permissions that are part of the content libraries API
Public permissions that are part of the content libraries API.
Deprecated. This module re-exports legacy content library permissions.
See https://github.com/openedx/openedx-platform/issues/37409.
"""
# pylint: disable=unused-import

View File

@@ -1,5 +1,8 @@
"""
Permissions for Content Libraries (v2, openedx_content-based)
Deprecated: The legacy permission rules and constants that rely on ContentLibraryPermission
are deprecated in favor of openedx-authz. See https://github.com/openedx/openedx-platform/issues/37409.
"""
from bridgekeeper import perms, rules
from bridgekeeper.rules import Attribute, ManyRelation, Relation, blanket_rule, in_current_groups, Rule