Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restricted runs to be considered conditionally active #987

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions enterprise_catalog/apps/catalog/content_metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down
Loading