Instead of going up the stacktrace to find the module names of waffle
flags and switches, we manually pass the module __name__ whenever the
flag is created. This is similar to `logging.getLogger(__name__)`
standard behaviour.
As the waffle classes are used outside of edx-platform, we make the new
module_name argument an optional keyword argument. This will change once
we pull waffle_utils outside of edx-platform.
Note that the module name is normally only required to view the list of
existing waffle flags and switches. The module name should not be
necessary to verify if a flag is enabled. Thus, maybe it would make
sense to create a `add` class methor similar to:
class WaffleFlag:
@classmethod
def add(cls, namespace, flag, module):
instance = cls(namespace, flag)
cls._class_instances.add((instance, module))
29 lines
1013 B
Python
29 lines
1013 B
Python
"""
|
|
Toggles for course home experience.
|
|
"""
|
|
|
|
from lms.djangoapps.experiments.flags import ExperimentWaffleFlag
|
|
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace
|
|
|
|
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='course_home')
|
|
|
|
COURSE_HOME_MICROFRONTEND = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'course_home_mfe', __name__)
|
|
|
|
COURSE_HOME_MICROFRONTEND_DATES_TAB = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'course_home_mfe_dates_tab', __name__)
|
|
|
|
COURSE_HOME_MICROFRONTEND_OUTLINE_TAB = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'course_home_mfe_outline_tab', __name__)
|
|
|
|
|
|
def course_home_mfe_dates_tab_is_active(course_key):
|
|
return (
|
|
COURSE_HOME_MICROFRONTEND.is_enabled(course_key) and
|
|
COURSE_HOME_MICROFRONTEND_DATES_TAB.is_enabled(course_key)
|
|
)
|
|
|
|
|
|
def course_home_mfe_outline_tab_is_active(course_key):
|
|
return (
|
|
COURSE_HOME_MICROFRONTEND.is_enabled(course_key) and
|
|
COURSE_HOME_MICROFRONTEND_OUTLINE_TAB.is_enabled(course_key)
|
|
)
|