-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
good first issueA good task for a newcomer to start withA good task for a newcomer to start withhelp wantedReady to be picked up by anyone in the communityReady to be picked up by anyone in the community
Description
Enhance BaseToggle with additional methods.
Add the following:
- is_disabled: Returns not
is_enabled
. - is_toggled_on: Returns
is_enabled
. - is_toggled_off: Returns not
is_enabled
.
This should make a variety of conditions more readable when ENABLE_
or DISABLE_
are in the toggle name.
Example 1: is_disabled
# BEFORE: slightly less readable
not SOME_FEATURE_TOGGLE.is_enabled()
# AFTER: more clear
SOME_FEATURE_TOGGLE.is_disabled()
Example 2: is_toggled_off
# BEFORE: brain twister
not DISABLE_SOME_FEATURE.is_enabled()
# AFTER: more clear
DISABLE_SOME_FEATURE.is_toggled_off()
Notes:
- For a
DISABLE_FEATURE
toggle, the toggle is off when the feature is on, so we use_toggle_
in the method nameis_toggled_off
to clearly refer to the toggle and not the feature. - For docs, possibly add an “Other ways to check a toggle” (or something like that) after https://github.com/openedx/edx-toggles/blob/master/docs/how_to/implement_the_right_toggle_type.rst#accessing-toggles?
- Similar change is needed for CourseWaffleFlag in edx-platform, which is slightly different because it takes an argument for is_enabled.
Questions:
Is this in fact simpler to understand? Are there better options?- We've decided to move forward
Work required:
- feat:added toggle methods to basemodel #293
- Update docs (see notes)
- Update CourseWaffleFlag in edx-platform (see notes).
Metadata
Metadata
Assignees
Labels
good first issueA good task for a newcomer to start withA good task for a newcomer to start withhelp wantedReady to be picked up by anyone in the communityReady to be picked up by anyone in the community