Skip to content

Commit fb5d598

Browse files
feanilclaude
andcommitted
refactor: migrate ENABLE_COURSE_FILENAME_CCX_SUFFIX off FEATURES-as-dict
`common/djangoapps/util/file.py` read the flag via `settings.FEATURES.get('ENABLE_COURSE_FILENAME_CCX_SUFFIX', False)`. The setting is defined only in lms/envs/common.py, but this reader lives in common/ and is reachable from CMS, so use `getattr(settings, 'ENABLE_COURSE_FILENAME_CCX_SUFFIX', False)` to avoid an AttributeError under Studio settings. Convert the test's whole-dict `@override_settings(FEATURES={...})` to `@override_settings(ENABLE_COURSE_FILENAME_CCX_SUFFIX=True)`. Verified the CCX-suffix tests pass under both lms.envs.test and cms.envs.test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 07a0997 commit fb5d598

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

common/djangoapps/util/file.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ def course_filename_prefix_generator(course_id, separator='_'):
115115
course_id.run
116116
])
117117

118-
enable_course_filename_ccx_suffix = settings.FEATURES.get(
119-
'ENABLE_COURSE_FILENAME_CCX_SUFFIX',
120-
False
118+
enable_course_filename_ccx_suffix = getattr(
119+
settings, 'ENABLE_COURSE_FILENAME_CCX_SUFFIX', False
121120
)
122121

123122
if enable_course_filename_ccx_suffix and getattr(course_id, 'ccx', None):

common/djangoapps/util/tests/test_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_locators(self, course_key):
5656
[CCXLocator.from_course_locator(CourseLocator(org='foo', course='bar', run='baz'), '1'), 'foo_bar_baz_ccx_1'],
5757
)
5858
@ddt.unpack
59-
@override_settings(FEATURES={'ENABLE_COURSE_FILENAME_CCX_SUFFIX': True})
59+
@override_settings(ENABLE_COURSE_FILENAME_CCX_SUFFIX=True)
6060
def test_include_ccx_id(self, course_key, expected_filename):
6161
"""
6262
Test filename prefix genaration from multiple course key formats.
@@ -82,7 +82,7 @@ def test_custom_separator(self, course_key):
8282
[CCXLocator.from_course_locator(CourseLocator(org='foo', course='bar', run='baz'), '1'), 'foo-bar-baz-ccx-1'],
8383
)
8484
@ddt.unpack
85-
@override_settings(FEATURES={'ENABLE_COURSE_FILENAME_CCX_SUFFIX': True})
85+
@override_settings(ENABLE_COURSE_FILENAME_CCX_SUFFIX=True)
8686
def test_custom_separator_including_ccx_id(self, course_key, expected_filename):
8787
"""
8888
Test filename prefix is generated with a custom separator.

0 commit comments

Comments
 (0)