Skip to content

Commit d009235

Browse files
feanilclaude
andcommitted
feat: remove ENABLE_MKTG_SITE from LMS branding views
index() (served at /) now unconditionally checks MKTG_URLS['ROOT'] and redirects when it differs from LMS_ROOT_URL, matching the previous ENABLE_MKTG_SITE=True behaviour. The catalog MFE redirect (ENABLE_CATALOG_MICROFRONTEND) still fires first and is unaffected. Also fixes a pre-existing bug where log.error() in the NoReverseMatch handler was passed multiple f-strings as positional args, causing a TypeError when that branch was reached. courses() (served at /courses) now resolves in priority order: 1. Redirect to the catalog MFE if ENABLE_CATALOG_MICROFRONTEND is set 2. Permanent redirect to marketing_link('COURSES') from MKTG_URLS 3. Render the local course list via courseware.views.views.courses() The old ENABLE_MKTG_SITE gate and COURSES_ARE_BROWSABLE guard are removed. The local course list fallback (case 3) preserves behaviour for operators who have neither the catalog MFE nor MKTG_URLS['COURSES'] configured. The stanford-style theme footer is updated to use marketing_link() instead of reverse() for the 'about' and 'tos' URL routes, which are removed in a later commit. Tests drop their @override_settings(ENABLE_MKTG_SITE=True) decorators; the test names and assertions are otherwise unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b982e44 commit d009235

4 files changed

Lines changed: 23 additions & 45 deletions

File tree

lms/djangoapps/branding/tests/test_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class TestFooter(TestCase):
4646
"""Test retrieving the footer. """
4747
maxDiff = None
4848

49-
@mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True})
5049
@mock.patch.dict('django.conf.settings.MKTG_URLS', {
5150
"ROOT": "https://edx.org",
5251
"ENTERPRISE": "/enterprise"
@@ -62,7 +61,6 @@ def test_footer_business_links_no_marketing_query_params(self):
6261
business_links = _footer_business_links()
6362
assert business_links[0]['url'] == 'https://edx.org/enterprise'
6463

65-
@mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True})
6664
@mock.patch.dict('django.conf.settings.MKTG_URLS', {
6765
"ROOT": "https://edx.org",
6866
"ABOUT": "/about-us",

lms/djangoapps/branding/tests/test_views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,12 @@ def test_index_does_not_redirect_without_site_override(self):
268268
response = self.client.get(reverse("root"))
269269
assert response.status_code == 200
270270

271-
@override_settings(ENABLE_MKTG_SITE=True)
272271
@override_settings(MKTG_URLS={'ROOT': 'https://foo.bar/'})
273272
@override_settings(LMS_ROOT_URL='https://foo.bar/')
274273
def test_index_wont_redirect_to_marketing_root_if_it_matches_lms_root(self):
275274
response = self.client.get(reverse("root"))
276275
assert response.status_code == 200
277276

278-
@override_settings(ENABLE_MKTG_SITE=True)
279277
@override_settings(MKTG_URLS={'ROOT': 'https://home.foo.bar/'})
280278
@override_settings(LMS_ROOT_URL='https://foo.bar/')
281279
def test_index_will_redirect_to_new_root_if_mktg_site_is_enabled(self):

lms/djangoapps/branding/views.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,13 @@ def index(request):
4848
if use_catalog_mfe():
4949
return redirect(f'{settings.CATALOG_MICROFRONTEND_URL}/', permanent=True)
5050

51-
enable_mktg_site = configuration_helpers.get_value(
52-
'ENABLE_MKTG_SITE',
53-
getattr(settings, 'ENABLE_MKTG_SITE', False)
51+
marketing_urls = configuration_helpers.get_value(
52+
'MKTG_URLS',
53+
settings.MKTG_URLS
5454
)
55-
56-
if enable_mktg_site:
57-
marketing_urls = configuration_helpers.get_value(
58-
'MKTG_URLS',
59-
settings.MKTG_URLS
60-
)
61-
root_url = marketing_urls.get("ROOT")
62-
if root_url != getattr(settings, "LMS_ROOT_URL", None):
63-
return redirect(root_url)
55+
root_url = marketing_urls.get("ROOT")
56+
if root_url and root_url != getattr(settings, "LMS_ROOT_URL", None):
57+
return redirect(root_url)
6458

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

@@ -76,11 +70,10 @@ def index(request):
7670
return student_views.index(request, user=request.user)
7771
except NoReverseMatch:
7872
log.error(
79-
f'https is not a registered namespace Request from {domain}',
80-
f'request_site= {request.site.__dict__}',
81-
f'enable_mktg_site= {enable_mktg_site}',
82-
f'Auth Status= {request.user.is_authenticated}',
83-
f'Request Meta= {request.META}'
73+
f'NoReverseMatch on index view for domain {domain}; '
74+
f'request_site={getattr(request, "site", None)}; '
75+
f'Auth Status={request.user.is_authenticated}; '
76+
f'Request Meta={request.META}'
8477
)
8578
raise
8679

@@ -89,26 +82,15 @@ def index(request):
8982
@cache_if_anonymous()
9083
def courses(request):
9184
"""
92-
Render the "find courses" page. If the marketing site is enabled, redirect
93-
to that. Otherwise, if subdomain branding is on, this is the university
94-
profile page. Otherwise, it's the edX courseware.views.views.courses page
85+
Serve the "find courses" page. Redirects to the catalog MFE or the marketing
86+
site COURSES URL if configured; falls back to rendering the local courses page.
9587
"""
9688
if use_catalog_mfe():
9789
return redirect(f'{settings.CATALOG_MICROFRONTEND_URL}/courses', permanent=True)
9890

99-
enable_mktg_site = configuration_helpers.get_value(
100-
'ENABLE_MKTG_SITE',
101-
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
102-
)
103-
104-
if enable_mktg_site:
105-
return redirect(marketing_link('COURSES'), permanent=True)
106-
107-
if not settings.FEATURES.get('COURSES_ARE_BROWSABLE'):
108-
raise Http404
109-
110-
# we do not expect this case to be reached in cases where
111-
# marketing is enabled or the courses are not browsable
91+
courses_url = marketing_link('COURSES')
92+
if courses_url != '#':
93+
return redirect(courses_url, permanent=True)
11294
return courseware_views.courses(request)
11395

11496

themes/stanford-style/lms/templates/footer.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## mako
22
<%!
33
from datetime import date
4-
from django.urls import reverse
54
from django.utils.translation import gettext as _
65
from openedx.core.djangoapps.lang_pref.api import footer_language_selector_is_enabled
6+
from common.djangoapps.edxmako.shortcuts import marketing_link
77
%>
88
<%namespace name='static' file='static_content.html'/>
99
<!-- footer overrides for stanford theme go here -->
@@ -12,13 +12,13 @@
1212
<div class="colophon">
1313
<nav class="nav-colophon">
1414
<ol>
15-
<li><a href="${reverse('about')}">${_("About")}</a></li>
16-
<li><a href="${reverse('about')}#careers">${_("Careers")}</a></li>
17-
<li><a href="${reverse('about')}#contact">${_("Contact")}</a></li>
18-
<li><a href="${reverse('tos')}">${_("Terms of Service")}</a></li>
19-
<li><a href="${reverse('tos')}#privacy">${_("Privacy Policy")}</a></li>
20-
<li><a href="${reverse('tos')}#honor">${_("Honor Code")}</a></li>
21-
<li><a href="${reverse('tos')}#copyright">${_("Copyright")}</a></li>
15+
<li><a href="${marketing_link('ABOUT')}">${_("About")}</a></li>
16+
<li><a href="${marketing_link('ABOUT')}#careers">${_("Careers")}</a></li>
17+
<li><a href="${marketing_link('ABOUT')}#contact">${_("Contact")}</a></li>
18+
<li><a href="${marketing_link('TOS')}">${_("Terms of Service")}</a></li>
19+
<li><a href="${marketing_link('TOS')}#privacy">${_("Privacy Policy")}</a></li>
20+
<li><a href="${marketing_link('TOS')}#honor">${_("Honor Code")}</a></li>
21+
<li><a href="${marketing_link('TOS')}#copyright">${_("Copyright")}</a></li>
2222
</ol>
2323
</nav>
2424

0 commit comments

Comments
 (0)