Skip to content

Conversation

@jkachel
Copy link
Contributor

@jkachel jkachel commented Jan 30, 2026

What are the relevant tickets?

Closes mitodl/hq#9951
Closes mitodl/hq#9955

Description (What does it do?)

Strips out B2B-related courseware from the v2/courses API:

  • Removes course runs that are associated with a contract, unless org_id is specified
  • Removes programs that are marked as b2b_only, unless org_id is specified

B2B-specific stuff shouldn't be in these anyway unless we're specifically looking for it.

How can this be tested?

Configure a course to have at least one run that's publicly accessible and one that's attached to a contract. Add it to a program that's marked as B2B only, and one that isn't. Then, hit the API: http://mitxonline.odl.local:9080/api/schema/swagger-ui/#/courses/api_v2_courses_list

You should only see the B2B runs if you've specified the org or contract that the run is in. By default, you shouldn't see the B2B run. This should work if you're listing out all the courses, or if you're loading the specific course.

Similarly, for programs, you should only see the B2B program if you've specified an org or contract. (Note that, in this case, you have to specify the readable_id to get programs as part of the result set. If you don't specify a readable ID, you won't get programs at all.)

@github-actions
Copy link

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:


## Changes for v1.yaml:


## Changes for v2.yaml:


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

Comment on lines 121 to 123
programs_list = [
program for program in programs_list if not program.b2b_only
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Waiting to try out the code while courseware_url_path update is made. One question, though:

Would /v2/coures/?readable_id=READABLE_ID&org_id=org1 include programs in the programs field that are b2b_only but for a different org?

@jkachel jkachel force-pushed the jkachel/9951-filter-b2b-courseruns-from-courses-v2 branch from 257fe61 to 576e706 Compare February 2, 2026 17:16
Chris noted that the programs list isn't filtered by contract or org if either option is specified; thought on it a bit and this seems to be a reasonably efficient way to do that. Note that we don't deliver programs unless you're loading a _specific_ course.
If an org_id or contract_id is specified along with a readable_id, it should display the course's associated programs that belong to the specified contract/org. This requires that the contract have a ContractProgramItem record, because otherwise we don't link programs to contracts. Adding the program should do this but it also can be done in Wagtail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants