Skip to content
Open
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
4 changes: 3 additions & 1 deletion cms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions cms/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down