Protection for when there is no CourseOverview data available.
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import logging
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
|
||||
log = logging.getLogger("common.entitlements.utils")
|
||||
|
||||
|
||||
def is_course_run_entitlement_fulfillable(course_run_key, entitlement, compare_date=timezone.now()):
|
||||
"""
|
||||
@@ -22,6 +26,13 @@ def is_course_run_entitlement_fulfillable(course_run_key, entitlement, compare_d
|
||||
"""
|
||||
course_overview = CourseOverview.get_from_id(course_run_key)
|
||||
|
||||
if not course_overview:
|
||||
log.error(('There is no CourseOverview entry available for {course_run_id}, '
|
||||
'course run cannot be applied to entitlement').format(
|
||||
course_run_id=str(course_run_key)
|
||||
))
|
||||
return False
|
||||
|
||||
# Verify that the course is still running
|
||||
run_start = course_overview.start
|
||||
run_end = course_overview.end
|
||||
|
||||
Reference in New Issue
Block a user