From 62f2bc646972fe85f1a809dcb01e25f0d96b8fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Ch=C3=A1vez?= Date: Thu, 19 Oct 2023 12:19:50 -0500 Subject: [PATCH 1/2] feat: New link on studio home to Taxonomy list (if waffle flag set) (#33439) --- .../rest_api/v1/serializers/home.py | 2 ++ .../rest_api/v1/tests/test_home.py | 17 ++++++++++++++++- cms/djangoapps/contentstore/toggles.py | 18 ++++++++++++++++++ cms/djangoapps/contentstore/utils.py | 15 +++++++++++++++ cms/templates/index.html | 3 +++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers/home.py b/cms/djangoapps/contentstore/rest_api/v1/serializers/home.py index 5abcda673aa7..aefab2c6b1df 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/serializers/home.py +++ b/cms/djangoapps/contentstore/rest_api/v1/serializers/home.py @@ -47,7 +47,9 @@ class CourseHomeSerializer(serializers.Serializer): in_process_course_actions = UnsucceededCourseSerializer(many=True, required=False, allow_null=True) libraries = LibraryViewSerializer(many=True, required=False, allow_null=True) libraries_enabled = serializers.BooleanField() + taxonomies_enabled = serializers.BooleanField() library_authoring_mfe_url = serializers.CharField() + taxonomy_list_mfe_url = serializers.CharField() optimization_enabled = serializers.BooleanField() redirect_to_library_authoring_mfe = serializers.BooleanField() request_course_creator_url = serializers.CharField() diff --git a/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py b/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py index 268014ea2126..1e578c657c7b 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py +++ b/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py @@ -5,11 +5,15 @@ import json from django.conf import settings from django.urls import reverse -from edx_toggles.toggles.testutils import override_waffle_switch +from edx_toggles.toggles.testutils import ( + override_waffle_switch, + override_waffle_flag, +) from rest_framework import status from cms.djangoapps.contentstore.tests.utils import CourseTestCase from cms.djangoapps.contentstore.views.course import ENABLE_GLOBAL_STAFF_OPTIMIZATION +from cms.djangoapps.contentstore.toggles import ENABLE_TAGGING_TAXONOMY_LIST_PAGE from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE from xmodule.modulestore.tests.factories import CourseFactory @@ -52,7 +56,9 @@ def test_home_page_response(self): "in_process_course_actions": [], "libraries": [], "libraries_enabled": True, + "taxonomies_enabled": False, "library_authoring_mfe_url": settings.LIBRARY_AUTHORING_MICROFRONTEND_URL, + "taxonomy_list_mfe_url": None, "optimization_enabled": False, "redirect_to_library_authoring_mfe": False, "request_course_creator_url": "/request_course_creator", @@ -90,3 +96,12 @@ def test_org_query_if_empty(self): response = self.client.get(self.url) self.assertEqual(len(response.data['courses']), 0) self.assertEqual(response.status_code, status.HTTP_200_OK) + + @override_waffle_flag(ENABLE_TAGGING_TAXONOMY_LIST_PAGE, True) + def test_taxonomy_list_link(self): + response = self.client.get(self.url) + self.assertTrue(response.data['taxonomies_enabled']) + self.assertEqual( + response.data['taxonomy_list_mfe_url'], + f'{settings.COURSE_AUTHORING_MICROFRONTEND_URL}/taxonomy-list' + ) diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py index ff2ad24fc7b6..5370d506f854 100644 --- a/cms/djangoapps/contentstore/toggles.py +++ b/cms/djangoapps/contentstore/toggles.py @@ -414,3 +414,21 @@ def use_new_unit_page(course_key): Returns a boolean if new studio course outline mfe is enabled """ return ENABLE_NEW_STUDIO_UNIT_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_tagging_taxonomy_list_page +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the taxonomy list page. +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-10-06 +# .. toggle_target_removal_date: TBA +# .. toggle_warning: +ENABLE_TAGGING_TAXONOMY_LIST_PAGE = WaffleFlag('new_studio_mfe.use_tagging_taxonomy_list_page', __name__) + + +def use_tagging_taxonomy_list_page(): + """ + Returns a boolean if taxonomy list page is enabled + """ + return ENABLE_TAGGING_TAXONOMY_LIST_PAGE.is_enabled() diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index befafcc865f3..abd80fecd40c 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -63,6 +63,7 @@ use_new_updates_page, use_new_video_editor, use_new_video_uploads_page, + use_tagging_taxonomy_list_page, ) from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order @@ -382,6 +383,18 @@ def get_unit_url(course_locator) -> str: return unit_url +def get_taxonomy_list_url(): + """ + Gets course authoring microfrontend URL for taxonomy list page view. + """ + taxonomy_list_url = None + if use_tagging_taxonomy_list_page(): + mfe_base_url = settings.COURSE_AUTHORING_MICROFRONTEND_URL + if mfe_base_url: + taxonomy_list_url = f'{mfe_base_url}/taxonomy-list' + return taxonomy_list_url + + def course_import_olx_validation_is_enabled(): """ Check if course olx validation is enabled on course import. @@ -1130,9 +1143,11 @@ def format_in_process_course_view(uca): 'archived_courses': archived_courses, 'in_process_course_actions': in_process_course_actions, 'libraries_enabled': LIBRARIES_ENABLED, + 'taxonomies_enabled': use_tagging_taxonomy_list_page(), 'redirect_to_library_authoring_mfe': should_redirect_to_library_authoring_mfe(), 'library_authoring_mfe_url': LIBRARY_AUTHORING_MICROFRONTEND_URL, 'libraries': [_format_library_for_view(lib, request) for lib in libraries], + 'taxonomy_list_mfe_url': get_taxonomy_list_url(), 'show_new_library_button': user_can_create_library(user) and not should_redirect_to_library_authoring_mfe(), 'user': user, 'request_course_creator_url': reverse('request_course_creator'), diff --git a/cms/templates/index.html b/cms/templates/index.html index dbd83b2ff518..766d68da780c 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -360,6 +360,9 @@

${course_info['display_name']}

% endif % endif + % if taxonomies_enabled: +
  • ${_("Taxonomies")}
  • + % endif % endif From bcce1d749bc1e761599684e174f12587be5d586a Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Thu, 9 May 2024 18:33:57 -0500 Subject: [PATCH 2/2] fix: update course-authoring path --- cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py | 2 +- cms/djangoapps/contentstore/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py b/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py index 1e578c657c7b..825de0ad9f21 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py +++ b/cms/djangoapps/contentstore/rest_api/v1/tests/test_home.py @@ -103,5 +103,5 @@ def test_taxonomy_list_link(self): self.assertTrue(response.data['taxonomies_enabled']) self.assertEqual( response.data['taxonomy_list_mfe_url'], - f'{settings.COURSE_AUTHORING_MICROFRONTEND_URL}/taxonomy-list' + f'{settings.COURSE_AUTHORING_MICROFRONTEND_URL}/taxonomies' ) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index abd80fecd40c..c6ebe173b5dc 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -391,7 +391,7 @@ def get_taxonomy_list_url(): if use_tagging_taxonomy_list_page(): mfe_base_url = settings.COURSE_AUTHORING_MICROFRONTEND_URL if mfe_base_url: - taxonomy_list_url = f'{mfe_base_url}/taxonomy-list' + taxonomy_list_url = f'{mfe_base_url}/taxonomies' return taxonomy_list_url