diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e5bff6b87..0e27d3c7e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,10 @@ Unreleased ---------- * nothing unreleased +[5.8.0] +-------- +* feat: exposes Waffle flag for MFEs' incremental migration to querying Algolia with non-enterprise-specific data + [5.7.0] -------- * feat: adds endpoint to list group memberships for a learner diff --git a/enterprise/__init__.py b/enterprise/__init__.py index 679154a9f..cf7cdb2ed 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "5.7.0" +__version__ = "5.8.0" diff --git a/enterprise/toggles.py b/enterprise/toggles.py index 24ab57538..a3b7fd612 100644 --- a/enterprise/toggles.py +++ b/enterprise/toggles.py @@ -91,6 +91,18 @@ ENTERPRISE_LOG_PREFIX, ) +# .. toggle_name: enterprise.catalog_query_search_filters_enabled +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: Enables filtering search results by catalog queries vs. enterprise-specific attributes. +# .. toggle_use_cases: open_edx +# .. toggle_creation_date: 2025-03-02 +CATALOG_QUERY_SEARCH_FILTERS_ENABLED = WaffleFlag( + f'{ENTERPRISE_NAMESPACE}.catalog_query_search_filters_enabled', + __name__, + ENTERPRISE_LOG_PREFIX, +) + def top_down_assignment_real_time_lcm(): """ @@ -141,6 +153,13 @@ def admin_portal_learner_profile_view_enabled(): return ADMIN_PORTAL_LEARNER_PROFILE_VIEW_ENABLED.is_enabled() +def catalog_query_search_filters_enabled(): + """ + Returns whether the catalog query search filters feature flag is enabled. + """ + return CATALOG_QUERY_SEARCH_FILTERS_ENABLED.is_enabled() + + def enterprise_features(): """ Returns a dict of enterprise Waffle-based feature flags. @@ -153,4 +172,5 @@ def enterprise_features(): 'enterprise_groups_v2': enterprise_groups_v2(), 'enterprise_learner_bff_enabled': enterprise_learner_bff_enabled(), 'admin_portal_learner_profile_view_enabled': admin_portal_learner_profile_view_enabled(), + 'catalog_query_search_filters_enabled': catalog_query_search_filters_enabled(), } diff --git a/tests/test_enterprise/api/test_filters.py b/tests/test_enterprise/api/test_filters.py index 7eb978adc..2f6761452 100644 --- a/tests/test_enterprise/api/test_filters.py +++ b/tests/test_enterprise/api/test_filters.py @@ -307,6 +307,7 @@ def test_filter(self, is_staff, is_linked_to_enterprise, has_access): 'enterprise_groups_v2': False, 'enterprise_learner_bff_enabled': False, 'admin_portal_learner_profile_view_enabled': False, + 'catalog_query_search_filters_enabled': False, } } assert response == mock_empty_200_success_response diff --git a/tests/test_enterprise/api/test_views.py b/tests/test_enterprise/api/test_views.py index 899031078..f589137ff 100644 --- a/tests/test_enterprise/api/test_views.py +++ b/tests/test_enterprise/api/test_views.py @@ -72,6 +72,7 @@ from enterprise.roles_api import admin_role from enterprise.toggles import ( ADMIN_PORTAL_LEARNER_PROFILE_VIEW_ENABLED, + CATALOG_QUERY_SEARCH_FILTERS_ENABLED, ENTERPRISE_CUSTOMER_SUPPORT_TOOL, ENTERPRISE_GROUPS_V1, ENTERPRISE_GROUPS_V2, @@ -2027,64 +2028,65 @@ def test_enterprise_customer_support_tool( @ddt.data( # Request missing required permissions query param. (True, False, [], {}, False, {'detail': 'User is not allowed to access the view.'}, - False, False, False, False, False, False, False), + False, False, False, False, False, False, False, False), # Staff user that does not have the specified group permission. (True, False, [], {'permissions': ['enterprise_enrollment_api_access']}, False, - {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False), + {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False, False), # Staff user that does have the specified group permission. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access']}, - True, None, False, False, False, False, False, False, False), + True, None, False, False, False, False, False, False, False, False), # Non staff user that is not linked to the enterprise, nor do they have the group permission. (False, False, [], {'permissions': ['enterprise_enrollment_api_access']}, False, - {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False), + {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False, False), # Non staff user that is not linked to the enterprise, but does have the group permission. (False, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access']}, - False, None, False, False, False, False, False, False, False), + False, None, False, False, False, False, False, False, False, False), # Non staff user that is linked to the enterprise, but does not have the group permission. (False, True, [], {'permissions': ['enterprise_enrollment_api_access']}, False, - {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False), + {'detail': 'User is not allowed to access the view.'}, False, False, False, False, False, False, False, False), # Non staff user that is linked to the enterprise and does have the group permission (False, True, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access']}, - True, None, False, False, False, False, False, False, False), + True, None, False, False, False, False, False, False, False, False), # Non staff user that is linked to the enterprise and has group permission and the request has passed # multiple groups to check. (False, True, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access', 'enterprise_data_api_access']}, True, None, False, - False, False, False, False, False, False), + False, False, False, False, False, False, False), # Staff user with group permission filtering on non existent enterprise id. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'enterprise_id': FAKE_UUIDS[1]}, False, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permission filtering on enterprise id successfully. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'enterprise_id': FAKE_UUIDS[0]}, True, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permission filtering on search param with no results. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'search': 'blah'}, False, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permission filtering on search param with results. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'search': 'test'}, True, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permission filtering on slug with results. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'slug': TEST_SLUG}, True, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permissions filtering on slug with no results. (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'slug': 'blah'}, False, - None, False, False, False, False, False, False, False), + None, False, False, False, False, False, False, False, False), # Staff user with group permission filtering on slug with results, with # top down assignment & real-time LCM feature enabled, # prequery search results enabled and # enterprise groups v1 feature enabled # enterprise groups v2 feature enabled # enterprise customer support tool enabled - # enterprise learner bff enabled + # enterprise learner bff enabled, + # admin portal learner profile view enabled (True, False, ['enterprise_enrollment_api_access'], {'permissions': ['enterprise_enrollment_api_access'], 'slug': TEST_SLUG}, True, - None, True, True, True, True, True, True, True), + None, True, True, True, True, True, True, True, True), ) @ddt.unpack @mock.patch('enterprise.utils.get_logo_url') @@ -2103,6 +2105,7 @@ def test_enterprise_customer_with_access_to( enterprise_customer_support_tool_enabled, enterprise_learner_bff_enabled, admin_portal_learner_profile_view_enabled, + catalog_query_search_filters_enabled, mock_get_logo_url, ): """ @@ -2152,7 +2155,6 @@ def test_enterprise_customer_with_access_to( TOP_DOWN_ASSIGNMENT_REAL_TIME_LCM, active=is_top_down_assignment_real_time_lcm_enabled ): - response = client.get( f"{settings.TEST_SERVER}{ENTERPRISE_CUSTOMER_WITH_ACCESS_TO_ENDPOINT}?{urlencode(query_params, True)}" ) @@ -2160,7 +2162,6 @@ def test_enterprise_customer_with_access_to( FEATURE_PREQUERY_SEARCH_SUGGESTIONS, active=feature_prequery_search_suggestions_enabled ): - response = client.get( f"{settings.TEST_SERVER}{ENTERPRISE_CUSTOMER_WITH_ACCESS_TO_ENDPOINT}?{urlencode(query_params, True)}" ) @@ -2199,6 +2200,13 @@ def test_enterprise_customer_with_access_to( response = client.get( f"{settings.TEST_SERVER}{ENTERPRISE_CUSTOMER_WITH_ACCESS_TO_ENDPOINT}?{urlencode(query_params, True)}" ) + with override_waffle_flag( + CATALOG_QUERY_SEARCH_FILTERS_ENABLED, + active=catalog_query_search_filters_enabled + ): + response = client.get( + f"{settings.TEST_SERVER}{ENTERPRISE_CUSTOMER_WITH_ACCESS_TO_ENDPOINT}?{urlencode(query_params, True)}" + ) response = self.load_json(response.content) if has_access_to_enterprise: assert response['results'][0] == { @@ -2271,6 +2279,7 @@ def test_enterprise_customer_with_access_to( 'enterprise_groups_v2': enterprise_groups_v2_enabled, 'enterprise_learner_bff_enabled': enterprise_learner_bff_enabled, 'admin_portal_learner_profile_view_enabled': admin_portal_learner_profile_view_enabled, + 'catalog_query_search_filters_enabled': catalog_query_search_filters_enabled, } } assert response in (expected_error, mock_empty_200_success_response)