From 32622573b83d4a7ed9f97a1946690789d32b90b0 Mon Sep 17 00:00:00 2001 From: zamanafzal Date: Tue, 30 Jun 2026 11:30:48 +0500 Subject: [PATCH] feat: default new certificate page title to courseware title create_default_certificate_page seeded product_name with "PLACEHOLDER - Certificate"; default it to the courseware title so new certificate pages are display-ready (admins can still overwrite). The CEUs placeholder is unchanged. Co-Authored-By: Claude Opus 4.7 --- cms/api.py | 4 +++- cms/api_test.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cms/api.py b/cms/api.py index c788aef2f9..3f00e17048 100644 --- a/cms/api.py +++ b/cms/api.py @@ -336,7 +336,9 @@ def create_default_certificate_page( from cms.models import CertificatePage # noqa: PLC0415 cert_page = CertificatePage( - product_name=f"PLACEHOLDER - {courseware.title} Certificate", + # Default to the courseware title so new certificate pages are + # display-ready; admins can still overwrite the "Certificate Title". + product_name=courseware.title, CEUs=f"PLACEHOLDER - {courseware.title} CEUs", ) courseware_page = courseware.page diff --git a/cms/api_test.py b/cms/api_test.py index 8035e2f46c..6464f9e7e1 100644 --- a/cms/api_test.py +++ b/cms/api_test.py @@ -12,6 +12,7 @@ from cms.api import ( RESOURCE_PAGE_TITLES, + create_default_certificate_page, create_default_courseware_page, create_featured_items, ensure_home_page_and_site, @@ -290,6 +291,22 @@ def test_create_courseware_page(): resulting_page = create_default_courseware_page(course.programs[0]) +@pytest.mark.django_db +def test_create_default_certificate_page_defaults_to_title(): + """New certificate pages default the title to the courseware title, not a placeholder.""" + ensure_home_page_and_site() + ensure_product_index() + ensure_program_product_index() + + course = CourseFactory.create(page=None) + create_default_courseware_page(course) + + cert_page = create_default_certificate_page(course) + + assert cert_page.product_name == course.title + assert "PLACEHOLDER" not in cert_page.product_name + + @pytest.mark.django_db def test_create_featured_items(): # pytest does not clear cache thus if we have a cache value set, it will persist between tests and test runs