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))
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""
|
|
Toggles for Learner Profile page.
|
|
"""
|
|
|
|
|
|
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
|
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
|
|
|
|
|
|
# Namespace for learner profile waffle flags.
|
|
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='learner_profile')
|
|
|
|
# Waffle flag to redirect to another learner profile experience.
|
|
# .. toggle_name: learner_profile.redirect_to_microfrontend
|
|
# .. toggle_implementation: WaffleFlag
|
|
# .. toggle_default: False
|
|
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the profile page.
|
|
# .. toggle_category: micro-frontend
|
|
# .. toggle_use_cases: incremental_release, open_edx
|
|
# .. toggle_creation_date: 2019-02-19
|
|
# .. toggle_expiration_date: 2020-12-31
|
|
# .. toggle_warnings: Also set settings.PROFILE_MICROFRONTEND_URL and site's ENABLE_PROFILE_MICROFRONTEND.
|
|
# .. toggle_tickets: DEPR-17
|
|
# .. toggle_status: supported
|
|
REDIRECT_TO_PROFILE_MICROFRONTEND = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'redirect_to_microfrontend', __name__)
|
|
|
|
|
|
def should_redirect_to_profile_microfrontend():
|
|
return (
|
|
configuration_helpers.get_value('ENABLE_PROFILE_MICROFRONTEND') and
|
|
REDIRECT_TO_PROFILE_MICROFRONTEND.is_enabled()
|
|
)
|