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

fix: restricted runs can be marketable and that's fine #997

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions enterprise_catalog/apps/api/v2/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_get_content_metadata_content_filters(
'key': 'course-v1:edX+course+run1',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
],
Expand All @@ -207,14 +207,14 @@ def test_get_content_metadata_content_filters(
'key': 'course-v1:edX+course+run1',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
{
'key': 'course-v1:edX+course+run2',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
],
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_get_content_metadata_with_no_restriction_type(
'key': 'course-v1:edX+course+run1',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
],
Expand All @@ -424,14 +424,14 @@ def test_get_content_metadata_with_no_restriction_type(
'key': 'course-v1:edX+course+run1',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
{
'key': 'course-v1:edX+course+run2',
'status': 'published',
'is_enrollable': True,
'is_marketable': False,
'is_marketable': True,
COURSE_RUN_RESTRICTION_TYPE_KEY: RESTRICTION_FOR_B2B,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from enterprise_catalog.apps.api.v1.views.enterprise_catalog_get_content_metadata import (
EnterpriseCatalogGetContentMetadata,
)
from enterprise_catalog.apps.api.v2.utils import is_any_course_run_active


logger = logging.getLogger(__name__)
Expand All @@ -27,21 +26,3 @@ def get_queryset(self, **kwargs):
)

return queryset.order_by('catalog_queries')

def is_active(self, item):
"""
Determines if a content item is active.
Args:
item (ContentMetadata): The content metadata item to check.
Returns:
bool: True if the item is active, False otherwise.
For courses, checks if any course run is active.
For other content types, always returns True.
"""
if item.content_type == 'course':
active = is_any_course_run_active(
item.json_metadata.get('course_runs', []))
if not active:
logger.debug(f'[get_content_metadata]: Content item {item.content_key} is not active.')
return active
return True
Loading