Skip to content

Paginate /codes endpoint#3685

Open
dsubak wants to merge 16 commits into
mainfrom
dansubak/202606_paginated_codes
Open

Paginate /codes endpoint#3685
dsubak wants to merge 16 commits into
mainfrom
dansubak/202606_paginated_codes

Conversation

@dsubak

@dsubak dsubak commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

https://github.com/mitodl/hq/issues/11375

Description (What does it do?)

  • Primarily this PR adds filtering and pagination to /codes. Filtering takes a single search_term argument which is used to search across assigned emails and names or redeemed user emails and names.
  • At the moment it also paginates /contracts, /course_runs and /enrollments due to pagination being done for the whole viewset. We can avoid doing that if we'd like, but /enrollments may have a cardinality similar to that of /codes, so my thinking is that we should at least paginate those two endpoints.

How can this be tested?

  • With a b2b contract set up, assign a few codes using a few different emails and users. You can get the list of codes by visiting http://mitxonline.odl.local:9080/api/v0/b2b/manager/organizations/<org_id>/contracts/<contract_id>/codes/, and it's easiest to assign the codes using the swagger UI for /assign
  • You'll also want to set up a few course runs and enrollments in order to view pagination on those endpoints.
  • Lastly, to fully test the filtering behavior, you'll want to redeem a few codes using the attach API.

Pagination

  • Visit /codes, /course_runs and /enrollments and /contracts. Observe that each of them returns a paginated response now.
  • If you have enough records for the endpoint, observe that you can modify the page_size and page parameters. The responses should reflect these params.

Filtering

  • Using the swagger UI for /codes, specify a search term corresponding to the emails or names you used when assigning them. Your response should have only records which have a substring match on either their name or email.
    • For assigned but unredeemed codes, the search term should filter on the assigned name or assigned email
    • For codes which have been assigned and redeemed, the search term should filter on the assigned name, assigned email, the redeemed email or redeemed user name.

Additional Info

  • This is obviously pretty chock full of breaking changes. Danielle and I will coordinate on scheduling this breaking change to minimize downtime

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
40 changes: 5 error, 0 warning, 35 info
error	[response-body-type-changed] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `results` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `assigned_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `redeemed_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `unassigned_codes` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page_size`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `search_term`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `status`

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v0.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `results` to the response with the `200` status



## Changes for v1.yaml:
40 changes: 5 error, 0 warning, 35 info
error	[response-body-type-changed] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `results` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `assigned_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `redeemed_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `unassigned_codes` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page_size`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `search_term`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `status`

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v1.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `results` to the response with the `200` status



## Changes for v2.yaml:
40 changes: 5 error, 0 warning, 35 info
error	[response-body-type-changed] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

error	[response-body-type-changed] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		the response's body type/format changed from `array`/`` to `object`/`` for status `200`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/
		added the required property `results` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `assigned_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `redeemed_codes` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/
		added the required property `unassigned_codes` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `page_size`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `search_term`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the new optional `query` request parameter `status`

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/codes/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/
		added the required property `results` to the response with the `200` status

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page`

info	[new-optional-request-parameter] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the new optional `query` request parameter `page_size`

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `next` to the response with the `200` status

info	[response-optional-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the optional property `previous` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `count` to the response with the `200` status

info	[response-required-property-added] at head/openapi/specs/v2.yaml
	in API GET /api/v0/b2b/manager/organizations/{parent_lookup_organization}/contracts/{id}/course_runs/{course_run_id}/enrollments/
		added the required property `results` to the response with the `200` status



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

Comment thread b2b/views/v0/manager.py Outdated
# We have seats available, so grab some more codes.
codes_for_output = list(discounts.all()[: contract.max_learners])

paginator = PageNumberPagination()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It sucks to do this in the view itself - we should probably bite the bullet and paginate the whole viewset.

@dsubak dsubak marked this pull request as ready for review June 22, 2026 15:54

@jkachel jkachel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small thing, but otherwise ready to go.

Comment thread b2b/views/v0/manager.py
@dsubak

dsubak commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@jkachel Think this is ready for another look!

@dsubak dsubak requested a review from jkachel June 23, 2026 17:03
Comment thread b2b/views/v0/manager.py Outdated
Comment thread b2b/views/v0/manager.py Outdated
@dsubak dsubak force-pushed the dansubak/202606_paginated_codes branch from 6351d78 to 6b1146e Compare June 23, 2026 20:37
Comment thread b2b/views/v0/manager.py Outdated
class ManagerContractOrgPagination(PageNumberPagination):
page_size = 25
page_size_query_param = "page_size"
max_page_size = 100

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Spoke w/ @daniellefrappier18 about using the /codes endpoint directly to support the export to csv behavior. At the moment, we think we can use that endpoint directly and reconstruct the payload as a CSV on the frontend - it'll just mean we specify a page_size large enough to pull back all rows in one shot.

I'm gonna need to remove this max_page_size endpoint to facilitate this approach. We may need to revisit it if this endpoint is too slow or the response too big to come back but for now we'll explore this approach and revisit it if it causes issues.

Image

@jkachel jkachel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread b2b/views/v0/manager.py Outdated
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.

4 participants