From 31218a568132589c30bde29798393f66ec5ad302 Mon Sep 17 00:00:00 2001 From: Paulo Viadanna Date: Mon, 9 Sep 2024 08:54:15 -0300 Subject: [PATCH 1/6] fix: unhide discussions when enabling it --- .../djangoapps/discussions/serializers.py | 8 ++++++++ .../discussions/tests/test_views.py | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/openedx/core/djangoapps/discussions/serializers.py b/openedx/core/djangoapps/discussions/serializers.py index 88648a4995..5e042575a2 100644 --- a/openedx/core/djangoapps/discussions/serializers.py +++ b/openedx/core/djangoapps/discussions/serializers.py @@ -354,6 +354,14 @@ class DiscussionsConfigurationSerializer(serializers.ModelSerializer): key not in LegacySettingsSerializer.Meta.fields_cohorts ) } + # Toggle discussion tab is_hidden. Before Palm, we would mark the discussion tab with the is_hidden property. + # Redwood and later, we disable discussions entirely by toggling the discussion configuration enabled property. + # This ensures pre-Palm courses import with discussions tab appropriately shown/hidden. + for tab in course.tabs: + if tab.tab_id == 'discussion' and tab.is_hidden == validated_data.get('enabled'): + tab.is_hidden = not validated_data.get('enabled') + save = True + break if save: modulestore().update_item(course, self.context['user_id']) return instance diff --git a/openedx/core/djangoapps/discussions/tests/test_views.py b/openedx/core/djangoapps/discussions/tests/test_views.py index b9663af8ed..64d342480a 100644 --- a/openedx/core/djangoapps/discussions/tests/test_views.py +++ b/openedx/core/djangoapps/discussions/tests/test_views.py @@ -384,6 +384,26 @@ class DataTest(AuthorizedApiTest, DataTestMixin): assert data['plugin_configuration'] == {'key': 'value'} assert data['lti_configuration'] == DEFAULT_LTI_CONFIGURATION + @ddt.data( + True, + False, + ) + def test_enabled_configuration(self, enabled): + """ + Test that setting the "enabled" property for Discussions shows the Discussions tab. + """ + payload = { + "provider_type": Provider.PIAZZA, + "enabled": enabled, + } + self._post(payload) + + data = self.get() + for tab in self.store.get_course(self.course.id).tabs: + if tab.tab_id == "discussion": + assert data["enabled"] == (not tab.is_hidden) + break + def test_change_plugin_configuration(self): """ Tests custom config values persist that when changing discussion From 19014463b13849acc22f2e6db6a234206696f86d Mon Sep 17 00:00:00 2001 From: andrii-hantkovskyi <131773947+andrii-hantkovskyi@users.noreply.github.com> Date: Fri, 16 May 2025 15:37:41 +0300 Subject: [PATCH 2/6] feat: [AXM-2056] add catalog MFE enabled waffle flag (#2639) * feat: [AXM-2056] add catalog MFE enabled waffle flag * test: cover waffle with test * refactor: fix pylint error * refactor: redesign waffleflag & add new MFE toggle to FEATURES * test: update tests to new functionality * refactor: add toggle_use_cases to annotation * refactor: redesign again to use new approach * refactor: rename waffle flag variable & update description --------- Co-authored-by: Andrii --- lms/djangoapps/branding/test_toggles.py | 30 +++++++++++++++++++++ lms/djangoapps/branding/toggles.py | 36 +++++++++++++++++++++++++ lms/envs/common.py | 9 +++++++ lms/envs/mock.yml | 1 + 4 files changed, 76 insertions(+) create mode 100644 lms/djangoapps/branding/test_toggles.py create mode 100644 lms/djangoapps/branding/toggles.py diff --git a/lms/djangoapps/branding/test_toggles.py b/lms/djangoapps/branding/test_toggles.py new file mode 100644 index 0000000000..f4e10a5695 --- /dev/null +++ b/lms/djangoapps/branding/test_toggles.py @@ -0,0 +1,30 @@ +""" +Tests for toggles, where there is logic beyond enable/disable. +""" + +from unittest.mock import patch +import ddt +from django.test import TestCase + +from lms.djangoapps.branding.toggles import use_new_catalog_page + + +@ddt.ddt +class TestBrandingToggles(TestCase): + """ + Tests for toggles, where there is logic beyond enable/disable. + """ + + @ddt.data(True, False) + @patch("lms.djangoapps.branding.toggles.ENABLE_NEW_CATALOG_PAGE") + def test_use_new_catalog_page_enabled( + self, is_waffle_enabled, mock_enable_new_catalog_page + ): + # Given legacy catalog feature is / not enabled + mock_enable_new_catalog_page.is_enabled.return_value = is_waffle_enabled + + # When I check if the feature is enabled + should_use_new_catalog_page = use_new_catalog_page() + + # Then I respects waffle setting. + self.assertEqual(should_use_new_catalog_page, is_waffle_enabled) diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py new file mode 100644 index 0000000000..d183b852ae --- /dev/null +++ b/lms/djangoapps/branding/toggles.py @@ -0,0 +1,36 @@ +""" +Configuration for features of Branding +""" +from django.conf import settings +from edx_toggles.toggles import WaffleFlag + +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers + +# Namespace for Waffle flags related to branding +WAFFLE_FLAG_NAMESPACE = "new_catalog_mfe" + + +def catalog_mfe_enabled(): + """ + Determine if Catalog MFE is enabled, replacing student_dashboard + """ + return configuration_helpers.get_value( + 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND') + ) + + +# .. toggle_name: new_catalog_mfe.use_new_catalog_page +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: Set to True to enable the new catalog page. +# .. toggle_creation_date: 2025-05-15 +# .. toggle_target_removal_date: None +# .. toggle_use_cases: open_edx +ENABLE_NEW_CATALOG_PAGE = WaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.use_new_catalog_page', __name__) + + +def use_new_catalog_page(): + """ + Returns a boolean if new catalog page should be used. + """ + return ENABLE_NEW_CATALOG_PAGE.is_enabled() diff --git a/lms/envs/common.py b/lms/envs/common.py index 41ea8ffe72..e6c147fbae 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -881,6 +881,15 @@ FEATURES = { # toggle does not have a target removal date. 'ENABLE_AUTHN_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_AUTHN_MFE", False), + # .. toggle_name: FEATURES['ENABLE_CATALOG_MICROFRONTEND'] + # .. toggle_implementation: DjangoSetting + # .. toggle_default: False + # .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the catalog. + # .. toggle_use_cases: temporary, open_edx + # .. toggle_creation_date: 2025-05-15 + # .. toggle_target_removal_date: None + 'ENABLE_CATALOG_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_CATALOG_MFE", False), + ### ORA Feature Flags ### # .. toggle_name: FEATURES['ENABLE_ORA_ALL_FILE_URLS'] # .. toggle_implementation: DjangoSetting diff --git a/lms/envs/mock.yml b/lms/envs/mock.yml index 386388a887..0bcdf0e84b 100644 --- a/lms/envs/mock.yml +++ b/lms/envs/mock.yml @@ -552,6 +552,7 @@ FEATURES: ENABLE_API_DOCS: true ENABLE_ASYNC_ANSWER_DISTRIBUTION: true ENABLE_AUTHN_MICROFRONTEND: true + ENABLE_CATALOG_MICROFRONTEND: true ENABLE_AUTO_GENERATED_USERNAME: true ENABLE_BULK_USER_RETIREMENT: true ENABLE_CERTIFICATES_IDV_REQUIREMENT: true From 256511e19685e612969fbe6b0f61f5f24c14bbf1 Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 18 Jun 2025 16:42:50 +0300 Subject: [PATCH 3/6] refactor: set toggle_target_removal_date --- lms/djangoapps/branding/toggles.py | 2 +- lms/envs/common.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index d183b852ae..d5a12f013e 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -24,7 +24,7 @@ def catalog_mfe_enabled(): # .. toggle_default: False # .. toggle_description: Set to True to enable the new catalog page. # .. toggle_creation_date: 2025-05-15 -# .. toggle_target_removal_date: None +# .. toggle_target_removal_date: 2025-11-01 # .. toggle_use_cases: open_edx ENABLE_NEW_CATALOG_PAGE = WaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.use_new_catalog_page', __name__) diff --git a/lms/envs/common.py b/lms/envs/common.py index e6c147fbae..9dd85470f7 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -887,7 +887,7 @@ FEATURES = { # .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the catalog. # .. toggle_use_cases: temporary, open_edx # .. toggle_creation_date: 2025-05-15 - # .. toggle_target_removal_date: None + # .. toggle_target_removal_date: 2025-11-01 'ENABLE_CATALOG_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_CATALOG_MFE", False), ### ORA Feature Flags ### From 94ce8fa147d7e33166beae92a9ddc0c48bd648ba Mon Sep 17 00:00:00 2001 From: Andrii Date: Mon, 23 Jun 2025 19:08:59 +0300 Subject: [PATCH 4/6] refactor: remove per-page waffle flag in favour of global one --- lms/djangoapps/branding/test_toggles.py | 23 ++++++++--------------- lms/djangoapps/branding/toggles.py | 23 +---------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/lms/djangoapps/branding/test_toggles.py b/lms/djangoapps/branding/test_toggles.py index f4e10a5695..92bde93a71 100644 --- a/lms/djangoapps/branding/test_toggles.py +++ b/lms/djangoapps/branding/test_toggles.py @@ -2,11 +2,10 @@ Tests for toggles, where there is logic beyond enable/disable. """ -from unittest.mock import patch import ddt -from django.test import TestCase +from django.test import override_settings, TestCase -from lms.djangoapps.branding.toggles import use_new_catalog_page +from lms.djangoapps.branding.toggles import use_catalog_mfe @ddt.ddt @@ -16,15 +15,9 @@ class TestBrandingToggles(TestCase): """ @ddt.data(True, False) - @patch("lms.djangoapps.branding.toggles.ENABLE_NEW_CATALOG_PAGE") - def test_use_new_catalog_page_enabled( - self, is_waffle_enabled, mock_enable_new_catalog_page - ): - # Given legacy catalog feature is / not enabled - mock_enable_new_catalog_page.is_enabled.return_value = is_waffle_enabled - - # When I check if the feature is enabled - should_use_new_catalog_page = use_new_catalog_page() - - # Then I respects waffle setting. - self.assertEqual(should_use_new_catalog_page, is_waffle_enabled) + def test_use_catalog_mfe(self, enabled): + """ + Test the use_catalog_mfe toggle. + """ + with override_settings(FEATURES={'ENABLE_CATALOG_MICROFRONTEND': enabled}): + assert use_catalog_mfe() == enabled diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index d5a12f013e..e6e54ebbcb 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -2,35 +2,14 @@ Configuration for features of Branding """ from django.conf import settings -from edx_toggles.toggles import WaffleFlag from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers -# Namespace for Waffle flags related to branding -WAFFLE_FLAG_NAMESPACE = "new_catalog_mfe" - -def catalog_mfe_enabled(): +def use_catalog_mfe(): """ Determine if Catalog MFE is enabled, replacing student_dashboard """ return configuration_helpers.get_value( 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND') ) - - -# .. toggle_name: new_catalog_mfe.use_new_catalog_page -# .. toggle_implementation: WaffleFlag -# .. toggle_default: False -# .. toggle_description: Set to True to enable the new catalog page. -# .. toggle_creation_date: 2025-05-15 -# .. toggle_target_removal_date: 2025-11-01 -# .. toggle_use_cases: open_edx -ENABLE_NEW_CATALOG_PAGE = WaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.use_new_catalog_page', __name__) - - -def use_new_catalog_page(): - """ - Returns a boolean if new catalog page should be used. - """ - return ENABLE_NEW_CATALOG_PAGE.is_enabled() From 8ca0e17d62b27c0a7d9bc63eb10fba0e2dd3095c Mon Sep 17 00:00:00 2001 From: Andrii Date: Tue, 24 Jun 2025 18:37:04 +0300 Subject: [PATCH 5/6] refactor: get rid of env variable for ENABLE_CATALOG_MICROFRONTEND & simplify use_catalog_mfe() --- lms/djangoapps/branding/toggles.py | 2 +- lms/envs/common.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/branding/toggles.py b/lms/djangoapps/branding/toggles.py index e6e54ebbcb..ba7b3407d7 100644 --- a/lms/djangoapps/branding/toggles.py +++ b/lms/djangoapps/branding/toggles.py @@ -11,5 +11,5 @@ def use_catalog_mfe(): Determine if Catalog MFE is enabled, replacing student_dashboard """ return configuration_helpers.get_value( - 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND') + 'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES['ENABLE_CATALOG_MICROFRONTEND'] ) diff --git a/lms/envs/common.py b/lms/envs/common.py index 9dd85470f7..ea7f97556c 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -885,10 +885,10 @@ FEATURES = { # .. toggle_implementation: DjangoSetting # .. toggle_default: False # .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the catalog. - # .. toggle_use_cases: temporary, open_edx + # .. toggle_use_cases: temporary # .. toggle_creation_date: 2025-05-15 # .. toggle_target_removal_date: 2025-11-01 - 'ENABLE_CATALOG_MICROFRONTEND': os.environ.get("EDXAPP_ENABLE_CATALOG_MFE", False), + 'ENABLE_CATALOG_MICROFRONTEND': False, ### ORA Feature Flags ### # .. toggle_name: FEATURES['ENABLE_ORA_ALL_FILE_URLS'] From b0316a03251e6580138b0b760dea1432cc893ed7 Mon Sep 17 00:00:00 2001 From: sameeramin <35958006+sameeramin@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:43:12 +0000 Subject: [PATCH 6/6] feat: Upgrade Python dependency enterprise-integrated-channels Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master` --- requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- requirements/edx/doc.txt | 2 +- requirements/edx/testing.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 6c2b7576df..ce3567fceb 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -566,7 +566,7 @@ enmerkar==0.7.1 # via enmerkar-underscore enmerkar-underscore==2.4.0 # via -r requirements/edx/kernel.in -enterprise-integrated-channels==0.1.6 +enterprise-integrated-channels==0.1.7 # via -r requirements/edx/bundled.in event-tracking==3.3.0 # via diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index fc92da6007..66201eb877 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -879,7 +879,7 @@ enmerkar-underscore==2.4.0 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt -enterprise-integrated-channels==0.1.6 +enterprise-integrated-channels==0.1.7 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index f03519ad2c..675592a536 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -653,7 +653,7 @@ enmerkar==0.7.1 # enmerkar-underscore enmerkar-underscore==2.4.0 # via -r requirements/edx/base.txt -enterprise-integrated-channels==0.1.6 +enterprise-integrated-channels==0.1.7 # via -r requirements/edx/base.txt event-tracking==3.3.0 # via diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 223012f587..0bbbe3f301 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -680,7 +680,7 @@ enmerkar==0.7.1 # enmerkar-underscore enmerkar-underscore==2.4.0 # via -r requirements/edx/base.txt -enterprise-integrated-channels==0.1.6 +enterprise-integrated-channels==0.1.7 # via -r requirements/edx/base.txt event-tracking==3.3.0 # via