Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mfe control setting #787

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lms/djangoapps/course_home_api/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from edx_toggles.toggles import LegacyWaffleFlagNamespace

from lms.lib.utils import use_learning_legacy_frontend
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='course_home')
Expand All @@ -26,7 +27,10 @@


def course_home_legacy_is_active(course_key):
return COURSE_HOME_USE_LEGACY_FRONTEND.is_enabled(course_key) or course_key.deprecated
return (
use_learning_legacy_frontend() and
(COURSE_HOME_USE_LEGACY_FRONTEND.is_enabled(course_key) or course_key.deprecated)
)


def course_home_mfe_progress_tab_is_active(course_key):
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from edx_toggles.toggles import LegacyWaffleFlagNamespace, SettingToggle
from opaque_keys.edx.keys import CourseKey

from lms.lib.utils import use_learning_legacy_frontend
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

# Namespace for courseware waffle flags.
Expand Down Expand Up @@ -140,7 +141,7 @@ def courseware_mfe_is_active(course_key: CourseKey) -> bool:
return False
# NO: MFE courseware can be disabled for users/courses/globally via this
# Waffle flag.
if COURSEWARE_USE_LEGACY_FRONTEND.is_enabled(course_key):
if use_learning_legacy_frontend() and COURSEWARE_USE_LEGACY_FRONTEND.is_enabled(course_key):
return False
# NO: Course preview doesn't work in the MFE
if in_preview_mode():
Expand Down
17 changes: 17 additions & 0 deletions lms/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Helper methods for the LMS.
"""

from django.conf import settings


def get_parent_unit(xblock):
"""
Expand Down Expand Up @@ -44,3 +46,18 @@ def is_unit(xblock):
"""

return get_parent_unit(xblock) is None and xblock.get_parent()


def use_learning_legacy_frontend() -> bool:
"""
THIS WILL BE OBSOLETE FROM VERSIONS HIGHER THAN NUTMEG
https://docs.openedx.org/en/latest/community/release_notes/olive.html#learning-mfe-is-now-required

Checks in django settings if use the learning legacy
frontend instead the learning mfe.

Returns:
True if the legacy frontend setting is activated, by default
legacy would be activated.
"""
return bool(getattr(settings, "USE_LEARNING_LEGACY_FRONTEND", True))
2 changes: 1 addition & 1 deletion requirements/edx/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ openedx-filters # Open edX Filters from Hooks Extension Fram
ora2
piexif # Exif image metadata manipulation, used in the profile_images app
Pillow # Image manipulation library; used for course assets, profile images, invoice PDFs, etc.
py2neo # Driver for converting Python modulestore structures to Neo4j's schema (for Coursegraph).
py2neo @ https://github.com/overhangio/py2neo/releases/download/2021.2.3/py2neo-2021.2.3.tar.gz
pycountry
pycryptodomex
pygments # Used to support colors in paver command output
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ psutil==5.9.0
# via
# -r requirements/edx/paver.txt
# edx-django-utils
py2neo==2021.2.3
py2neo @ https://github.com/overhangio/py2neo/releases/download/2021.2.3/py2neo-2021.2.3.tar.gz
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ py==1.11.0
# pytest
# pytest-forked
# tox
py2neo==2021.2.3
py2neo @ https://github.com/overhangio/py2neo/releases/download/2021.2.3/py2neo-2021.2.3.tar.gz
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ py==1.11.0
# pytest
# pytest-forked
# tox
py2neo==2021.2.3
py2neo @ https://github.com/overhangio/py2neo/releases/download/2021.2.3/py2neo-2021.2.3.tar.gz
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
Expand Down
Loading