Skip to content

Commit

Permalink
Merge pull request #905 from openedx/pwnage101/ENT-9209
Browse files Browse the repository at this point in the history
feat: support restricted/custom-b2b runs via enterprise_force_include_aggregation_keys
  • Loading branch information
pwnage101 authored Aug 12, 2024
2 parents 140de60 + 7a92dd6 commit f72db3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions enterprise_catalog/apps/api_client/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

LOGGER = logging.getLogger(__name__)

CUSTOM_B2B_RESTRICTION_TYPE_KEY = 'custom-b2b-enterprise'


class DiscoveryApiClient(BaseOAuthClient):
"""
Expand Down Expand Up @@ -294,7 +296,8 @@ def get_metadata_by_query(self, catalog_query):
raise exc

try:
# NOTE johnnagro this ONLY supports courses at the moment (NOT programs, leanerpathways, etc)
# NOTE johnnagro: This ONLY supports courses at the moment (NOT programs, leanerpathways, etc).
# NOTE Troy: This now also supports force-including restricted/custom-b2b courses.
if forced_aggregation_keys := catalog_query.content_filter.get('enterprise_force_include_aggregation_keys'):
LOGGER.info(
'get_metadata_by_query enterprise_force_include_aggregation_keys seen'
Expand Down Expand Up @@ -324,7 +327,7 @@ def _retrieve_courses(self, offset, request_params):

def get_courses(self, query_params=None):
"""
Return results from the discovery service's /courses endpoint.
Return results from the discovery service's /api/v1/courses/ endpoint.
Arguments:
query_params (dict): additional query params for the rest api endpoint
Expand All @@ -336,6 +339,11 @@ def get_courses(self, query_params=None):
request_params = {
'ordering': 'key',
'limit': DISCOVERY_OFFSET_SIZE,
# ALWAYS include restricted/custom-b2b courses in the search results. Usability/visiblility of restricted
# courses is ultimately controlled at the level of catalog inclusion, but this helper function is designed
# to facilitate fetching specific courses. Therefore, there's no reason to hide anything restricted at this
# level of the code.
'include_restricted': CUSTOM_B2B_RESTRICTION_TYPE_KEY,
}
request_params.update(query_params or {})

Expand Down

0 comments on commit f72db3f

Please sign in to comment.