Skip to content

Add a "certificate available" field so we can tell if the course has a cert available for it#3415

Merged
jkachel merged 2 commits intomainfrom
jkachel/update-certficate-type-for-nulls
Mar 24, 2026
Merged

Add a "certificate available" field so we can tell if the course has a cert available for it#3415
jkachel merged 2 commits intomainfrom
jkachel/update-certficate-type-for-nulls

Conversation

@jkachel
Copy link
Copy Markdown
Contributor

@jkachel jkachel commented Mar 23, 2026

What are the relevant tickets?

n/a

Description (What does it do?)

The Learn frontend uses the certificate_type field to determine what badge to display for the certificate for a given course. However, this doesn't work quite right if the course doesn't have a certificate, so this PR adds in a separate field that can be used to determine whether or not to display the badge.

How can this be tested?

Automated tests should pass.

The certificate_available field should be True if the next run has a certificate available. So, this can be tested by setting and clearing the certificate_available_date on the next run for a given course - if there is one, then it should be True and vice versa.

Additional Context

This uses the first_unexpired_run computed property, which the serializer uses elsewhere too, so it shouldn't incur any additional database overhead. The limitation of this is that if the next run doesn't have a cert, but a future one does, then we won't display the badge. Not sure if that's OK or if it should consider any future run instead.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 23, 2026

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
11 changes: 0 error, 0 warning, 11 info
info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/course_certificates/{cert_uuid}/
		added the required property 'course_run/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/courses/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/courses/{id}/
		added the required property 'certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/enrollments/
		added the required property '/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API POST /api/v2/enrollments/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.coursepage
		added the required property 'items/items/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/CoursePageItem]/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v0.yaml	
	in API POST /api/v2/verified_program_enrollments/{program_id}/{courserun_id}/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status



## Changes for v1.yaml:
11 changes: 0 error, 0 warning, 11 info
info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/course_certificates/{cert_uuid}/
		added the required property 'course_run/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/courses/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/courses/{id}/
		added the required property 'certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/enrollments/
		added the required property '/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API POST /api/v2/enrollments/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.coursepage
		added the required property 'items/items/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/CoursePageItem]/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v1.yaml	
	in API POST /api/v2/verified_program_enrollments/{program_id}/{courserun_id}/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status



## Changes for v2.yaml:
11 changes: 0 error, 0 warning, 11 info
info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/course_certificates/{cert_uuid}/
		added the required property 'course_run/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/courses/
		added the required property 'results/items/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/courses/{id}/
		added the required property 'certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/enrollments/
		added the required property '/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API POST /api/v2/enrollments/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/pages/?fields=*&type=cms.coursepage
		added the required property 'items/items/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/pages/{id}/
		added the required property '/oneOf[#/components/schemas/CoursePageItem]/course_details/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/program_enrollments/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API DELETE /api/v2/program_enrollments/{id}/
		added the required property '/items/enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API GET /api/v2/program_enrollments/{id}/
		added the required property 'enrollments/items/run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '200' status

info	[response-required-property-added] at head/openapi/specs/v2.yaml	
	in API POST /api/v2/verified_program_enrollments/{program_id}/{courserun_id}/
		added the required property 'run/allOf[#/components/schemas/V2CourseRunWithCourse]/course/allOf[#/components/schemas/V2Course]/certificate_available' to the response with the '201' status



Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Comment thread courses/serializers/v2/courses_test.py Outdated
Comment thread courses/serializers/v2/courses_test.py Outdated
@annagav annagav self-requested a review March 24, 2026 13:08
Copy link
Copy Markdown
Contributor

@annagav annagav left a comment

Choose a reason for hiding this comment

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

👍

@jkachel jkachel merged commit 71be021 into main Mar 24, 2026
10 checks passed
@jkachel jkachel deleted the jkachel/update-certficate-type-for-nulls branch March 24, 2026 15:40
@odlbot odlbot mentioned this pull request Mar 24, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants