Skip to content

Commit

Permalink
fix: restricted runs can be marketable and that's fine
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Nov 14, 2024
1 parent 23caf6b commit e9a3592
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
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

0 comments on commit e9a3592

Please sign in to comment.