diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py index dc5dd26e942e..ff2ad24fc7b6 100644 --- a/cms/djangoapps/contentstore/toggles.py +++ b/cms/djangoapps/contentstore/toggles.py @@ -175,3 +175,242 @@ def individualize_anonymous_user_id(course_id): __name__, CONTENTSTORE_LOG_PREFIX, ) + + +# .. toggle_name: new_studio_mfe.use_new_home_page +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio home page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-9306 +# .. toggle_warning: +ENABLE_NEW_STUDIO_HOME_PAGE = WaffleFlag('new_studio_mfe.use_new_home_page', __name__) + + +def use_new_home_page(): + """ + Returns a boolean if new studio home page mfe is enabled + """ + return ENABLE_NEW_STUDIO_HOME_PAGE.is_enabled() + + +# .. toggle_name: new_studio_mfe.use_new_custom_pages +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio custom pages mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_CUSTOM_PAGES = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_custom_pages', __name__) + + +def use_new_custom_pages(): + """ + Returns a boolean if new studio custom pages mfe is enabled + """ + return ENABLE_NEW_STUDIO_CUSTOM_PAGES.is_enabled() + + +# .. toggle_name: new_studio_mfe.use_new_schedule_details_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio schedule and details mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_SCHEDULE_DETAILS_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_schedule_details_page', __name__) + + +def use_new_schedule_details_page(course_key): + """ + Returns a boolean if new studio schedule and details mfe is enabled + """ + return ENABLE_NEW_STUDIO_SCHEDULE_DETAILS_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_advanced_settings_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio advanced settings page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_ADVANCED_SETTINGS_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_advanced_settings_page', __name__) + + +def use_new_advanced_settings_page(course_key): + """ + Returns a boolean if new studio advanced settings pafe mfe is enabled + """ + return ENABLE_NEW_STUDIO_ADVANCED_SETTINGS_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_grading_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio grading page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_GRADING_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_grading_page', __name__) + + +def use_new_grading_page(course_key): + """ + Returns a boolean if new studio grading mfe is enabled + """ + return ENABLE_NEW_STUDIO_GRADING_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_updates_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio updates page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_UPDATES_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_updates_page', __name__) + + +def use_new_updates_page(course_key): + """ + Returns a boolean if new studio updates mfe is enabled + """ + return ENABLE_NEW_STUDIO_UPDATES_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_import_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio import page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_IMPORT_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_import_page', __name__) + + +def use_new_import_page(course_key): + """ + Returns a boolean if new studio import mfe is enabled + """ + return ENABLE_NEW_STUDIO_IMPORT_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_export_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio export page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_EXPORT_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_export_page', __name__) + + +def use_new_export_page(course_key): + """ + Returns a boolean if new studio export mfe is enabled + """ + return ENABLE_NEW_STUDIO_EXPORT_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_files_uploads_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio files and uploads page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_FILES_UPLOADS_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_files_uploads_page', __name__) + + +def use_new_files_uploads_page(course_key): + """ + Returns a boolean if new studio files and uploads mfe is enabled + """ + return ENABLE_NEW_STUDIO_FILES_UPLOADS_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_video_uploads_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new video uploads page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_VIDEO_UPLOADS_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_video_uploads_page', __name__) + + +def use_new_video_uploads_page(course_key): + """ + Returns a boolean if new studio video uploads mfe is enabled + """ + return ENABLE_NEW_STUDIO_VIDEO_UPLOADS_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_course_outline_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio course outline page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_COURSE_OUTLINE_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_course_outline_page', __name__) + + +def use_new_course_outline_page(course_key): + """ + Returns a boolean if new studio course outline mfe is enabled + """ + return ENABLE_NEW_STUDIO_COURSE_OUTLINE_PAGE.is_enabled(course_key) + + +# .. toggle_name: new_studio_mfe.use_new_unit_page +# .. toggle_implementation: CourseWaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new studio course outline page mfe +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-5-15 +# .. toggle_target_removal_date: 2023-8-31 +# .. toggle_tickets: TNL-10619 +# .. toggle_warning: +ENABLE_NEW_STUDIO_UNIT_PAGE = CourseWaffleFlag( + f'{CONTENTSTORE_NAMESPACE}.new_studio_mfe.use_new_unit_page', __name__) + + +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) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index f51fa22313bc..3a8ade2fa964 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -26,7 +26,21 @@ from openedx.core.djangoapps.site_configuration.models import SiteConfiguration from openedx.features.content_type_gating.models import ContentTypeGatingConfig from openedx.features.content_type_gating.partitions import CONTENT_TYPE_GATING_SCHEME -from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_video_editor +from cms.djangoapps.contentstore.toggles import ( + use_new_text_editor, + use_new_video_editor, + use_new_advanced_settings_page, + use_new_course_outline_page, + use_new_export_page, + use_new_files_uploads_page, + use_new_grading_page, + use_new_home_page, + use_new_import_page, + use_new_schedule_details_page, + use_new_unit_page, + use_new_updates_page, + use_new_video_uploads_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 from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order @@ -202,6 +216,148 @@ def get_editor_page_base_url(course_locator) -> str: return editor_url +def get_studio_home_url(course_locator): + """ + Gets course authoring microfrontend URL for Studio Home view. + """ + studio_home_url = None + if use_new_home_page(): + mfe_base_url = get_course_authoring_url(course_locator) + if mfe_base_url: + studio_home_url = f'{mfe_base_url}/home' + return studio_home_url + + +def get_schedule_details_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for schedule and details pages view. + """ + schedule_details_url = None + if use_new_schedule_details_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/settings/details/{course_locator}' + if mfe_base_url: + schedule_details_url = course_mfe_url + return schedule_details_url + + +def get_advanced_settings_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for advanced settings page view. + """ + advanced_settings_url = None + if use_new_advanced_settings_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/settings/advanced/{course_locator}' + if mfe_base_url: + advanced_settings_url = course_mfe_url + return advanced_settings_url + + +def get_grading_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for grading page view. + """ + grading_url = None + if use_new_grading_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/settings/grading/{course_locator}' + if mfe_base_url: + grading_url = course_mfe_url + return grading_url + + +def get_updates_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for updates page view. + """ + updates_url = None + if use_new_updates_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/course_info/{course_locator}' + if mfe_base_url: + updates_url = course_mfe_url + return updates_url + + +def get_import_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for import page view. + """ + import_url = None + if use_new_import_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/import/{course_locator}' + if mfe_base_url: + import_url = course_mfe_url + return import_url + + +def get_export_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for export page view. + """ + export_url = None + if use_new_export_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/export/{course_locator}' + if mfe_base_url: + export_url = course_mfe_url + return export_url + + +def get_files_uploads_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for files and uploads page view. + """ + files_uploads_url = None + if use_new_files_uploads_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/assets/{course_locator}' + if mfe_base_url: + files_uploads_url = course_mfe_url + return files_uploads_url + + +def get_video_uploads_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for files and uploads page view. + """ + video_uploads_url = None + if use_new_video_uploads_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/assets/{course_locator}' + if mfe_base_url: + video_uploads_url = course_mfe_url + return video_uploads_url + + +def get_course_outline_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for course oultine page view. + """ + course_outline_url = None + if use_new_course_outline_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/course/{course_locator}' + if mfe_base_url: + course_outline_url = course_mfe_url + return course_outline_url + + +def get_unit_url(course_locator) -> str: + """ + Gets course authoring microfrontend URL for unit page view. + """ + unit_url = None + if use_new_unit_page(course_locator): + mfe_base_url = get_course_authoring_url(course_locator) + course_mfe_url = f'{mfe_base_url}/container/' + if mfe_base_url: + unit_url = course_mfe_url + return unit_url + + def course_import_olx_validation_is_enabled(): """ Check if course olx validation is enabled on course import.