refactor(course_modes): resolve default mode slug at runtime instead …#80
Closed
andrey-canon wants to merge 1 commit into
Closed
refactor(course_modes): resolve default mode slug at runtime instead …#80andrey-canon wants to merge 1 commit into
andrey-canon wants to merge 1 commit into
Conversation
…of import time Replaced the static class attribute `DEFAULT_MODE_SLUG` with a dynamic evaluation inside `get_default_mode_slug()`. This ensures that `settings.COURSE_MODE_DEFAULTS` is inspected at runtime rather than being frozen during server initialization, increasing configuration flexibility.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Currently, the default course enrollment mode slug is evaluated and frozen at import time during server startup via the static class attribute
CourseMode.DEFAULT_MODE_SLUG = settings.COURSE_MODE_DEFAULTS['slug'].This implementation restricts flexibility if the active Django settings context changes or needs to be evaluated dynamically beyond the initial boot sequence.
This PR refactors the class to remove the static
DEFAULT_MODE_SLUGconstant and updates all internal references to use theget_default_mode_slug()class method instead. The method now directly fetchessettings.COURSE_MODE_DEFAULTS['slug']on invocation, effectively shifting the configuration evaluation from import-time to runtime.