Skip to content

Commit 5c93291

Browse files
fixup! feat: check authz permissions for course tagging
1 parent 88f1560 commit 5c93291

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

openedx/core/djangoapps/content_tagging/auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from opaque_keys import InvalidKeyError
77
from opaque_keys.edx.keys import CourseKey
8-
from opaque_keys.edx.locator import LibraryLocatorV2
98
from openedx_authz import api as authz_api
109
from openedx_authz.constants.permissions import COURSES_EXPORT_TAGS
1110
from openedx_tagging import rules as oel_tagging_rules
@@ -52,17 +51,17 @@ def should_use_authz_for_object(object_id) -> tuple[bool, CourseKey | None]:
5251
- should_use_authz: True if authz should be used, False otherwise
5352
- course_key: The CourseKey if object is a course, None otherwise
5453
"""
55-
# Extract context_key and ensure it is a course_key
54+
# Extract context_key and ensure it is a CourseKey (not a LibraryLocatorV2, etc.)
5655
try:
5756
context_key = get_context_key_from_key_string(object_id)
58-
if not isinstance(context_key, CourseKey) or isinstance(context_key, LibraryLocatorV2):
57+
if not isinstance(context_key, CourseKey):
5958
return False, None
6059
except (ValueError, AttributeError):
6160
return False, None
6261

6362
# Check if toggle is active
6463
if not core_toggles.enable_authz_course_authoring(context_key):
65-
return False, context_key
64+
return False, None
6665

6766
# Authz should be used for this course object
6867
return True, context_key

openedx/core/djangoapps/content_tagging/rest_api/v1/tests/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ def setUp(self):
21652165
)
21662166
TaxonomyOrg.objects.create(
21672167
taxonomy=self.taxonomy,
2168-
org=None, # Global taxonomy not tied to any org
2168+
org=None, # Global taxonomy not tied to any org
21692169
rel_type=TaxonomyOrg.RelType.OWNER,
21702170
)
21712171

@@ -2298,7 +2298,7 @@ def test_no_role_user_denied_view(self):
22982298
def test_library_fallthrough_to_legacy(self):
22992299
"""Library object_id falls through to legacy permissions"""
23002300
# Create organization for library
2301-
org, created = Organization.objects.get_or_create(short_name="TestOrg")
2301+
org, _ = Organization.objects.get_or_create(short_name="TestOrg")
23022302

23032303
# Create library
23042304
library = create_library(

0 commit comments

Comments
 (0)