Skip to content

Commit

Permalink
feat: restricted runs to be considered conditionally active
Browse files Browse the repository at this point in the history
iloveagent57 committed Oct 23, 2024
1 parent 0eb18b0 commit 6096b23
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions enterprise_catalog/apps/catalog/content_metadata_utils.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,11 @@

from enterprise_catalog.apps.catalog.utils import get_content_key

from .constants import FORCE_INCLUSION_METADATA_TAG_KEY
from .constants import (
COURSE_RUN_RESTRICTION_TYPE_KEY,
FORCE_INCLUSION_METADATA_TAG_KEY,
RESTRICTION_FOR_B2B,
)


LOGGER = getLogger(__name__)
@@ -65,7 +69,16 @@ def get_course_run_by_uuid(course, course_run_uuid):
def is_course_run_active(course_run):
"""
Checks whether a course run is active. That is, whether the course run is published,
enrollable, and marketable.
enrollable, and either marketable, or has a b2b restriction type. To ellaborate on the latter:
Restricted course run records will be set with `is_marketable: false` from the
upstream source-of-truth (course-discovery). But because our discovery <-> catalog
synchronization has business logic that filters course run json metadata (inside of courses)
to only the *allowed* restricted runs for a catalog, we can safely assume
when looking at a course run metadata record in the context of a catalog,
if that run has a non-null, B2B restriction type, then it is permitted to be
part of the catalog and should be considered active (as long as it is published and enrollable).
Arguments:
course_run (dict): The metadata about a course run.
Returns:
@@ -75,8 +88,9 @@ def is_course_run_active(course_run):
is_published = course_run_status.lower() == 'published'
is_enrollable = course_run.get('is_enrollable', False)
is_marketable = course_run.get('is_marketable', False)
is_restricted = course_run.get(COURSE_RUN_RESTRICTION_TYPE_KEY) == RESTRICTION_FOR_B2B

return is_published and is_enrollable and is_marketable
return is_published and is_enrollable and (is_marketable or is_restricted)


def get_course_first_paid_enrollable_seat_price(course):

0 comments on commit 6096b23

Please sign in to comment.