feat: validate B2C course eligibility for B2C programs#58
Open
rjv31 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds admin-form validation to ensure Programs marked b2c_subscription_inclusion=True only include Courses that are also b2c_subscription_inclusion=True, preventing invalid B2C subscription program configurations from being saved.
Changes:
- Added B2C eligibility validation in
ProgramAdminForm.clean()that rejects non-compliant course selections and surfaces a non-field validation error listing offending courses. - Refactored
clean()to rely oncleaned_dataand queryset filtering. - Added tests covering valid B2C programs, invalid mixed-course B2C programs, and non-B2C programs with mixed courses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| course_discovery/apps/course_metadata/forms.py | Adds B2C course eligibility validation to ProgramAdminForm.clean(). |
| course_discovery/apps/course_metadata/tests/test_forms.py | Adds tests for B2C program validation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rjv31
force-pushed
the
feat/program-b2c-course-validation
branch
from
July 24, 2026 10:23
0e6e105 to
5a52714
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
course_discovery/apps/course_metadata/forms.py:120
- The
coursesvalue comes fromcleaned_datafor a ModelForm M2M field and should already be a QuerySet; thehasattr(courses, 'filter')branch and fallback query add complexity and make the validation harder to follow without providing value here.
if hasattr(courses, 'filter'):
invalid_titles = list(
courses.filter(b2c_subscription_inclusion=False)
.order_by('title')
.values_list('title', flat=True)
)
else:
invalid_titles = list(
Course.objects.filter(
id__in=[course.id for course in courses],
b2c_subscription_inclusion=False,
).order_by('title').values_list('title', flat=True)
)
rjv31
force-pushed
the
feat/program-b2c-course-validation
branch
from
July 24, 2026 10:43
5a52714 to
fb04cde
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds validation to ensure that Programs with b2c_subscription_inclusion=True can only contain Courses with b2c_subscription_inclusion=True.
Changes