Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lms/djangoapps/branding/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ def test_index_does_not_redirect_without_site_override(self):
response = self.client.get(reverse("root"))
assert response.status_code == 200

@override_settings(ENABLE_MKTG_SITE=True)
@override_settings(MKTG_URLS={'ROOT': 'https://foo.bar/'})
@override_settings(LMS_ROOT_URL='https://foo.bar/')
def test_index_wont_redirect_to_marketing_root_if_it_matches_lms_root(self):
response = self.client.get(reverse("root"))
assert response.status_code == 200

@override_settings(ENABLE_MKTG_SITE=True)
@override_settings(MKTG_URLS={'ROOT': 'https://home.foo.bar/'})
@override_settings(LMS_ROOT_URL='https://foo.bar/')
def test_index_will_redirect_to_new_root_if_mktg_site_is_enabled(self):
response = self.client.get(reverse("root"))
assert response.status_code == 302

def test_index_redirects_to_marketing_site_with_site_override(self):
""" Test index view redirects if MKTG_URLS['ROOT'] is set in SiteConfiguration """
self.use_site(self.site_other)
Expand Down
8 changes: 5 additions & 3 deletions lms/djangoapps/branding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,25 @@ def index(request):
# page to make it easier to browse for courses (and register)
if configuration_helpers.get_value(
'ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER',
settings.FEATURES.get('ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER', True)):
getattr(settings, 'ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER', True)):
return redirect('dashboard')

if use_catalog_mfe():
return redirect(f'{settings.CATALOG_MICROFRONTEND_URL}/', permanent=True)

enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
getattr(settings, 'ENABLE_MKTG_SITE', False)
)

if enable_mktg_site:
marketing_urls = configuration_helpers.get_value(
'MKTG_URLS',
settings.MKTG_URLS
)
return redirect(marketing_urls.get('ROOT'))
root_url = marketing_urls.get("ROOT")
if root_url != getattr(settings, "LMS_ROOT_URL", None):
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using getattr() with a default of None for LMS_ROOT_URL is inconsistent with how this setting is accessed elsewhere in the codebase. Throughout the project (e.g., in cms/djangoapps/contentstore/helpers.py and common/djangoapps/student/helpers.py), settings.LMS_ROOT_URL is accessed directly or via configuration_helpers.get_value(). Additionally, there's a system check in openedx/core/djangoapps/common_initialization/checks.py that validates LMS_ROOT_URL is defined. Change this to settings.LMS_ROOT_URL for consistency.

Suggested change
if root_url != getattr(settings, "LMS_ROOT_URL", None):
if root_url != settings.LMS_ROOT_URL:

Copilot uses AI. Check for mistakes.
return redirect(root_url)

domain = request.headers.get('Host')

Expand Down
Loading