diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 664d1d34da4..b92e8c3d25f 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -579,6 +579,10 @@ def format_in_process_course_view(uca): active_courses, archived_courses = _process_courses_list(courses_iter, in_process_course_actions, split_archived) in_process_course_actions = [format_in_process_course_view(uca) for uca in in_process_course_actions] + library_authoring_mfe_url = configuration_helpers.get_value( + 'LIBRARY_AUTHORING_MICROFRONTEND_URL', LIBRARY_AUTHORING_MICROFRONTEND_URL + ) + return render_to_response('index.html', { 'courses': active_courses, 'split_studio_home': split_library_view_on_dashboard(), @@ -586,7 +590,7 @@ def format_in_process_course_view(uca): 'in_process_course_actions': in_process_course_actions, 'libraries_enabled': LIBRARIES_ENABLED, 'redirect_to_library_authoring_mfe': should_redirect_to_library_authoring_mfe(), - 'library_authoring_mfe_url': LIBRARY_AUTHORING_MICROFRONTEND_URL, + 'library_authoring_mfe_url': library_authoring_mfe_url, 'libraries': [_format_library_for_view(lib, request) for lib in libraries], 'show_new_library_button': user_can_create_library(user) and not should_redirect_to_library_authoring_mfe(), 'user': user, diff --git a/common/djangoapps/student/management/commands/recover_account.py b/common/djangoapps/student/management/commands/recover_account.py index 78e45cdbb3f..a2c8e694b29 100644 --- a/common/djangoapps/student/management/commands/recover_account.py +++ b/common/djangoapps/student/management/commands/recover_account.py @@ -106,7 +106,9 @@ def send_password_reset_email(self, user, site): message_context = get_base_template_context(site) email = user.email if should_redirect_to_authn_microfrontend(): - site_url = settings.AUTHN_MICROFRONTEND_URL + site_url = configuration_helpers.get_value( + "AUTHN_MICROFRONTEND_URL", settings.AUTHN_MICROFRONTEND_URL + ) else: site_url = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME) message_context.update({ diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 0e73c3c2570..09ef6dd8383 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -522,7 +522,10 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem return redirect(reverse('account_settings')) if should_redirect_to_learner_home_mfe(user): - return redirect(settings.LEARNER_HOME_MICROFRONTEND_URL) + learner_home_mfe_url = configuration_helpers.get_value( + "LEARNER_HOME_MICROFRONTEND_URL", settings.LEARNER_HOME_MICROFRONTEND_URL + ) + return redirect(learner_home_mfe_url) platform_name = configuration_helpers.get_value("platform_name", settings.PLATFORM_NAME) diff --git a/common/djangoapps/student/views/management.py b/common/djangoapps/student/views/management.py index d131575193b..b0eab00da44 100644 --- a/common/djangoapps/student/views/management.py +++ b/common/djangoapps/student/views/management.py @@ -639,7 +639,10 @@ def activate_account(request, key): if redirect_url: params['next'] = redirect_url url_path = '/login?{}'.format(urllib.parse.urlencode(params)) - return redirect(settings.AUTHN_MICROFRONTEND_URL + url_path) + authn_mfe_url = configuration_helpers.get_value( + "AUTHN_MICROFRONTEND_URL", settings.AUTHN_MICROFRONTEND_URL + ) + return redirect(authn_mfe_url + url_path) response = redirect(redirect_url) if redirect_url and is_enterprise_learner(request.user) else redirect('dashboard') if show_account_activation_popup: diff --git a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py index be344dcb0d9..2c03bc6feee 100644 --- a/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py +++ b/lms/djangoapps/course_goals/management/commands/goal_reminder_email.py @@ -55,7 +55,10 @@ def send_ace_message(goal): course_home_url = get_learning_mfe_home_url(course_key=goal.course_key, url_fragment='home') - goals_unsubscribe_url = f'{settings.LEARNING_MICROFRONTEND_URL}/goal-unsubscribe/{goal.unsubscribe_token}' + learning_mfe_url = configuration_helpers.get_value( + "LEARNING_MICROFRONTEND_URL", settings.LEARNING_MICROFRONTEND_URL + ) + goals_unsubscribe_url = f'{learning_mfe_url}/goal-unsubscribe/{goal.unsubscribe_token}' language = get_user_preference(user, LANGUAGE_KEY) diff --git a/lms/djangoapps/discussion/views.py b/lms/djangoapps/discussion/views.py index 74a365bcdf8..ead61462b3d 100644 --- a/lms/djangoapps/discussion/views.py +++ b/lms/djangoapps/discussion/views.py @@ -67,6 +67,7 @@ from openedx.core.djangoapps.django_comment_common.utils import ThreadContext from openedx.core.djangoapps.plugin_api.views import EdxFragmentView from openedx.features.course_duration_limits.access import generate_course_expired_fragment +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers User = get_user_model() log = logging.getLogger("edx.discussions") @@ -274,7 +275,9 @@ def redirect_forum_url_to_new_mfe(request, course_id): redirect_url = None if discussions_mfe_enabled: - mfe_base_url = settings.DISCUSSIONS_MICROFRONTEND_URL + mfe_base_url = configuration_helpers.get_value( + "DISCUSSIONS_MICROFRONTEND_URL", settings.DISCUSSIONS_MICROFRONTEND_URL + ) redirect_url = f"{mfe_base_url}/{str(course_key)}" return redirect_url @@ -334,7 +337,9 @@ def redirect_thread_url_to_new_mfe(request, course_id, thread_id): discussions_mfe_enabled = ENABLE_DISCUSSIONS_MFE.is_enabled(course_key) redirect_url = None if discussions_mfe_enabled: - mfe_base_url = settings.DISCUSSIONS_MICROFRONTEND_URL + mfe_base_url = configuration_helpers.get_value( + "DISCUSSIONS_MICROFRONTEND_URL", settings.DISCUSSIONS_MICROFRONTEND_URL + ) if thread_id: redirect_url = f"{mfe_base_url}/{str(course_key)}/posts/{thread_id}" return redirect_url @@ -654,7 +659,9 @@ def user_profile(request, course_key, user_id): else: discussions_mfe_enabled = ENABLE_DISCUSSIONS_MFE.is_enabled(course_key) if discussions_mfe_enabled: - mfe_base_url = settings.DISCUSSIONS_MICROFRONTEND_URL + mfe_base_url = configuration_helpers.get_value( + "DISCUSSIONS_MICROFRONTEND_URL", settings.DISCUSSIONS_MICROFRONTEND_URL + ) return redirect(f"{mfe_base_url}/{str(course_key)}/learners") tab_view = CourseTabView() diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 579b8d035f9..dde431a3030 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -700,9 +700,12 @@ def _section_send_email(course, access): ), } if settings.FEATURES.get("ENABLE_NEW_BULK_EMAIL_EXPERIENCE", False) is not False: + communication_mfe_url = configuration_helpers.get_value( + "COMMUNICATIONS_MICROFRONTEND_URL", settings.COMMUNICATIONS_MICROFRONTEND_URL + ) section_data[ "communications_mfe_url" - ] = f"{settings.COMMUNICATIONS_MICROFRONTEND_URL}/courses/{str(course_key)}/bulk_email" + ] = f"{communication_mfe_url}/courses/{str(course_key)}/bulk_email" return section_data diff --git a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py index 04f75ef4243..3eca0a2f0fa 100644 --- a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py @@ -189,9 +189,12 @@ def send_verification_expiry_email(self, batch_verifications, email_config): site = Site.objects.get_current() message_context = get_base_template_context(site) + account_mfe_url = configuration_helpers.get_value( + "ACCOUNT_MICROFRONTEND_URL", settings.ACCOUNT_MICROFRONTEND_URL + ) message_context.update({ 'platform_name': settings.PLATFORM_NAME, - 'lms_verification_link': f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification', + 'lms_verification_link': f'{account_mfe_url}/id-verification', 'help_center_link': settings.ID_VERIFICATION_SUPPORT_LINK }) diff --git a/lms/djangoapps/verify_student/services.py b/lms/djangoapps/verify_student/services.py index bdfa31fee6d..d1cd2094575 100644 --- a/lms/djangoapps/verify_student/services.py +++ b/lms/djangoapps/verify_student/services.py @@ -232,7 +232,10 @@ def get_verify_location(cls, course_id=None): Returns a string: Returns URL for IDV on Account Microfrontend """ - location = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification' + account_mfe_url = configuration_helpers.get_value( + "ACCOUNT_MICROFRONTEND_URL", settings.ACCOUNT_MICROFRONTEND_URL + ) + location = f'{account_mfe_url}/id-verification' if course_id: location += f'?course_id={quote(str(course_id))}' return location diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 99cf7004992..8c174e43430 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -1120,9 +1120,12 @@ def results_callback(request): # lint-amnesty, pylint: disable=too-many-stateme send_verification_approved_email(context=email_context) elif result == "FAIL": + account_mfe_url = configuration_helpers.get_value( + "ACCOUNT_MICROFRONTEND_URL", settings.ACCOUNT_MICROFRONTEND_URL + ) log.debug("Denying verification for %s", receipt_id) attempt.deny(json.dumps(reason), error_code=error_code) - reverify_url = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification' + reverify_url = f'{account_mfe_url}/id-verification' verification_status_email_vars['reasons'] = reason verification_status_email_vars['reverify_url'] = reverify_url verification_status_email_vars['faq_url'] = settings.ID_VERIFICATION_SUPPORT_LINK diff --git a/lms/templates/header/navbar-not-authenticated.html b/lms/templates/header/navbar-not-authenticated.html index 47aa9abd2ce..8131b12f474 100644 --- a/lms/templates/header/navbar-not-authenticated.html +++ b/lms/templates/header/navbar-not-authenticated.html @@ -12,6 +12,7 @@ from six import text_type from openedx.core.djangoapps.user_authn.toggles import should_redirect_to_authn_microfrontend +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers %> <% @@ -21,6 +22,9 @@ can_discover_courses = settings.FEATURES.get('ENABLE_COURSE_DISCOVERY') allow_public_account_creation = static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')) should_redirect_to_authn_mfe = should_redirect_to_authn_microfrontend() + authn_mfe_url = configuration_helpers.get_value( + "AUTHN_MICROFRONTEND_URL", settings.AUTHN_MICROFRONTEND_URL + ) %> + diff --git a/lms/templates/header/user_dropdown.html b/lms/templates/header/user_dropdown.html index 2e7e168a693..cfbbbf66af5 100644 --- a/lms/templates/header/user_dropdown.html +++ b/lms/templates/header/user_dropdown.html @@ -12,6 +12,7 @@ from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user from openedx.core.djangoapps.user_api.accounts.toggles import should_redirect_to_order_history_microfrontend from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name, get_enterprise_learner_portal +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers %> <% @@ -24,6 +25,9 @@ ## Enterprises with the learner portal enabled should not show order history, as it does ## not apply to the learner's method of purchasing content. should_show_order_history = should_redirect_to_order_history_microfrontend() and not enterprise_customer_portal +order_history_mfe_url = configuration_helpers.get_value( + "ORDER_HISTORY_MICROFRONTEND_URL", settings.ORDER_HISTORY_MICROFRONTEND_URL +) %> diff --git a/openedx/core/djangoapps/discussions/url_helpers.py b/openedx/core/djangoapps/discussions/url_helpers.py index 60b29d91976..650debdbeab 100644 --- a/openedx/core/djangoapps/discussions/url_helpers.py +++ b/openedx/core/djangoapps/discussions/url_helpers.py @@ -6,6 +6,7 @@ from django.conf import settings from opaque_keys.edx.keys import CourseKey +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers def _get_url_with_view_query_params(path: str, view: Optional[str] = None) -> str: @@ -20,9 +21,12 @@ def _get_url_with_view_query_params(path: str, view: Optional[str] = None) -> st (str) URL link for MFE """ - if settings.DISCUSSIONS_MICROFRONTEND_URL is None: + discussion_mfe_url = configuration_helpers.get_value( + "DISCUSSIONS_MICROFRONTEND_URL", settings.DISCUSSIONS_MICROFRONTEND_URL + ) + if discussion_mfe_url is None: return '' - url = f"{settings.DISCUSSIONS_MICROFRONTEND_URL}/{path}" + url = f"{discussion_mfe_url}/{path}" query_params = {} if view == "in_context": diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index 002695d4e33..c1079e2da41 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -60,7 +60,9 @@ def account_settings(request): """ if should_redirect_to_account_microfrontend(): - url = settings.ACCOUNT_MICROFRONTEND_URL + url = configuration_helpers.get_value( + "ACCOUNT_MICROFRONTEND_URL", settings.ACCOUNT_MICROFRONTEND_URL + ) duplicate_provider = pipeline.get_duplicate_provider(messages.get_messages(request)) if duplicate_provider: diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py index ee04123ddf9..bfd6639c879 100644 --- a/openedx/core/djangoapps/user_authn/views/login_form.py +++ b/openedx/core/djangoapps/user_authn/views/login_form.py @@ -219,7 +219,10 @@ def login_and_registration_form(request, initial_mode="login"): initial_mode, '?' + query_params if query_params else '' ) - return redirect(settings.AUTHN_MICROFRONTEND_URL + url_path) + authn_mfe_url = configuration_helpers.get_value( + "AUTHN_MICROFRONTEND_URL", settings.AUTHN_MICROFRONTEND_URL + ) + return redirect(authn_mfe_url + url_path) # Account activation message account_activation_messages = [ diff --git a/openedx/features/course_experience/url_helpers.py b/openedx/features/course_experience/url_helpers.py index 0e52cee5798..838e4a3938a 100644 --- a/openedx/features/course_experience/url_helpers.py +++ b/openedx/features/course_experience/url_helpers.py @@ -17,6 +17,7 @@ from lms.djangoapps.courseware.toggles import courseware_mfe_is_active from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.search import navigation_index, path_to_location # lint-amnesty, pylint: disable=wrong-import-order +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers User = get_user_model() @@ -158,7 +159,10 @@ def make_learning_mfe_courseware_url( strings. They're only ever used to concatenate a URL string. `params` is an optional QueryDict object (e.g. request.GET) """ - mfe_link = f'{settings.LEARNING_MICROFRONTEND_URL}/course/{course_key}' + learning_mfe_url = configuration_helpers.get_value( + "LEARNING_MICROFRONTEND_URL", settings.LEARNING_MICROFRONTEND_URL + ) + mfe_link = f'{learning_mfe_url}/course/{course_key}' if sequence_key: mfe_link += f'/{sequence_key}' @@ -188,7 +192,10 @@ def get_learning_mfe_home_url( `url_fragment` is an optional string. `params` is an optional QueryDict object (e.g. request.GET) """ - mfe_link = f'{settings.LEARNING_MICROFRONTEND_URL}/course/{course_key}' + learning_mfe_url = configuration_helpers.get_value( + "LEARNING_MICROFRONTEND_URL", settings.LEARNING_MICROFRONTEND_URL + ) + mfe_link = f'{learning_mfe_url}/course/{course_key}' if url_fragment: mfe_link += f'/{url_fragment}' @@ -203,9 +210,12 @@ def is_request_from_learning_mfe(request: HttpRequest): """ Returns whether the given request was made by the frontend-app-learning MFE. """ - if not settings.LEARNING_MICROFRONTEND_URL: + learning_mfe_url = configuration_helpers.get_value( + "LEARNING_MICROFRONTEND_URL", settings.LEARNING_MICROFRONTEND_URL + ) + if not learning_mfe_url: return False - url = urlparse(settings.LEARNING_MICROFRONTEND_URL) + url = urlparse(learning_mfe_url) mfe_url_base = f'{url.scheme}://{url.netloc}' return request.META.get('HTTP_REFERER', '').startswith(mfe_url_base) diff --git a/openedx/features/learner_profile/views/learner_profile.py b/openedx/features/learner_profile/views/learner_profile.py index e19e6853e8e..9b9fc48da13 100644 --- a/openedx/features/learner_profile/views/learner_profile.py +++ b/openedx/features/learner_profile/views/learner_profile.py @@ -44,7 +44,10 @@ def learner_profile(request, username): GET /account/profile """ if should_redirect_to_profile_microfrontend(): - profile_microfrontend_url = f"{settings.PROFILE_MICROFRONTEND_URL}{username}" + profile_mfe_url = configuration_helpers.get_value( + "PROFILE_MICROFRONTEND_URL", settings.PROFILE_MICROFRONTEND_URL + ) + profile_microfrontend_url = f"{profile_mfe_url}{username}" if request.GET: profile_microfrontend_url += f'?{request.GET.urlencode()}' return redirect(profile_microfrontend_url)