From cff48d92b18167364f7e662bb312fe7d61d07feb Mon Sep 17 00:00:00 2001 From: Tycho Hob Date: Fri, 16 Oct 2026 14:18:03 -0400 Subject: [PATCH] fix: render certificates when no About URL is configured The certificate web view's "About" section rendered `company_about_url` unconditionally, but that name is only put in the context when an About page URL is configured: by an enabled CertificateHtmlViewConfiguration, the site configuration's `urls`, or the marketing URLs. Since the marketing link fallback to the LMS's own pages was removed, a default install has none of these, so `valid.html` raised `NameError: Undefined` and every learner's "View my certificate" link answered 500. Leave the "Learn more" link out when the URL is undefined, the same guard the certificate footer already uses for the Terms of Service and Privacy Policy links. Closes #39222 Co-Authored-By: Claude Opus 5.5 --- .../certificates/tests/test_webview_views.py | 20 +++++++++++++++++++ lms/templates/certificates/_about-edx.html | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/certificates/tests/test_webview_views.py b/lms/djangoapps/certificates/tests/test_webview_views.py index 9817ecd290a3..c3b88bac17bc 100644 --- a/lms/djangoapps/certificates/tests/test_webview_views.py +++ b/lms/djangoapps/certificates/tests/test_webview_views.py @@ -611,6 +611,26 @@ def test_render_html_view_valid_certificate(self): response = self.client.get(test_url) self.assertContains(response, str(self.cert.verify_uuid)) + @override_settings(CERTIFICATES_HTML_VIEW=True) + def test_render_html_view_without_about_url(self): + """ + Tests that the certificate renders when no About page URL is configured + anywhere: not in the HTML view configuration, the site configuration or + the marketing URLs. The "Learn more" link is left out rather than the + template failing on an undefined name. + """ + CertificateHtmlViewConfigurationFactory.create(enabled=False) + self._add_course_certificates(count=1, signatory_count=1) + test_url = get_certificate_url( + user_id=self.user.id, + course_id=str(self.course.id), + uuid=self.cert.verify_uuid + ) + response = self.client.get(test_url) + self.assertContains(response, str(self.cert.verify_uuid)) + self.assertContains(response, 'class="about-item about-edx"') + self.assertNotContains(response, 'Learn more about') + @override_settings(CERTIFICATES_HTML_VIEW=True) def test_render_certificate_only_for_downloadable_status(self): """ diff --git a/lms/templates/certificates/_about-edx.html b/lms/templates/certificates/_about-edx.html index 70b030852519..e25e292d45e0 100644 --- a/lms/templates/certificates/_about-edx.html +++ b/lms/templates/certificates/_about-edx.html @@ -6,6 +6,8 @@

${company_about_title}

${company_about_description}

- ${company_about_urltext} + % if company_about_url is not UNDEFINED: + ${company_about_urltext} + % endif