From 02556369c7eb7c9eaf45193a35210b9bcd812836 Mon Sep 17 00:00:00 2001 From: Johan Castiblanco Date: Fri, 27 Jan 2023 18:24:31 -0500 Subject: [PATCH 1/4] feat: add mfe control setting To use the learning mfe now you also need the setting `USE_LEGACY_FRONTEND` by tenant. feat: use function to verify lgacy frontend feat: improve docstring style: add type hints feat: update long line for large conditional feat: move imports for good practices move the import for utils and toogles and seems withou problems --- lms/djangoapps/course_home_api/toggles.py | 6 +++++- lms/djangoapps/courseware/toggles.py | 3 ++- lms/lib/utils.py | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/course_home_api/toggles.py b/lms/djangoapps/course_home_api/toggles.py index 8c8b8ad2150..9d197fabb52 100644 --- a/lms/djangoapps/course_home_api/toggles.py +++ b/lms/djangoapps/course_home_api/toggles.py @@ -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') @@ -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): diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index 4cea39e09c0..8b1b826fc86 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -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. @@ -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(): diff --git a/lms/lib/utils.py b/lms/lib/utils.py index 93287337824..77f1bff47f0 100644 --- a/lms/lib/utils.py +++ b/lms/lib/utils.py @@ -2,6 +2,8 @@ Helper methods for the LMS. """ +from django.conf import settings + def get_parent_unit(xblock): """ @@ -44,3 +46,15 @@ def is_unit(xblock): """ return get_parent_unit(xblock) is None and xblock.get_parent() + + +def use_learning_legacy_frontend() -> bool: + """ + 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)) From 0995668b26052c3d22ca24686ccd5f50b004baf5 Mon Sep 17 00:00:00 2001 From: Maria Fernanda Magallanes Zubillaga Date: Thu, 30 Nov 2023 10:08:36 -0500 Subject: [PATCH 2/4] fix: update py2neo --- requirements/edx/base.in | 2 +- requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/testing.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/edx/base.in b/requirements/edx/base.in index 34c0c79de1a..4299b86e8de 100644 --- a/requirements/edx/base.in +++ b/requirements/edx/base.in @@ -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 diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 61c5208e2e5..31918923c39 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -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 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 0ba47d465f2..9471358d29b 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -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 diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 881a36d5b8c..db574874b97 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -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 From 8b8d7ad8647a796f27b6f232cdba4ead9cf706ea Mon Sep 17 00:00:00 2001 From: Alejandro Cardenas Date: Wed, 6 Dec 2023 09:55:56 -0800 Subject: [PATCH 3/4] docs: add deprecation message --- lms/lib/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lms/lib/utils.py b/lms/lib/utils.py index 77f1bff47f0..48eb22c0082 100644 --- a/lms/lib/utils.py +++ b/lms/lib/utils.py @@ -50,6 +50,9 @@ def is_unit(xblock): 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. From 7c6f091e1c033f64b5b2ef1c6711026892c1f6ba Mon Sep 17 00:00:00 2001 From: Alejandro Cardenas Date: Wed, 6 Dec 2023 10:11:09 -0800 Subject: [PATCH 4/4] test: fix pylint trailing whitespace --- lms/lib/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/lib/utils.py b/lms/lib/utils.py index 48eb22c0082..97fc35edd8b 100644 --- a/lms/lib/utils.py +++ b/lms/lib/utils.py @@ -52,7 +52,7 @@ 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.