Merge pull request #30021 from openedx/mikix/guard-course-end
fix: add some extra guards for a None course.end value
This commit is contained in:
@@ -30,7 +30,7 @@ def _listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable
|
||||
verified_mode = CourseMode.objects.get(course_id=course_key, mode_slug=CourseMode.VERIFIED)
|
||||
if _should_update_date(verified_mode):
|
||||
course = modulestore().get_course(course_key)
|
||||
if not course:
|
||||
if not course or not course.end:
|
||||
return None
|
||||
verification_window = CourseModeExpirationConfig.current().verification_window
|
||||
new_expiration_datetime = course.end - verification_window
|
||||
|
||||
@@ -366,7 +366,7 @@ class CourseEndDate(DateSummary):
|
||||
Registers an alert if the end date is approaching.
|
||||
"""
|
||||
is_enrolled = CourseEnrollment.get_enrollment(request.user, course.id)
|
||||
if not course.start or self.current_time < course.start or not is_enrolled:
|
||||
if not course.start or not course.end or self.current_time < course.start or not is_enrolled:
|
||||
return
|
||||
days_until_end = (course.end - self.current_time).days
|
||||
if course.end > self.current_time and days_until_end <= settings.COURSE_MESSAGE_ALERT_DURATION_IN_DAYS:
|
||||
|
||||
@@ -183,7 +183,7 @@ def dates_banner_should_display(course_key, user):
|
||||
return False, False
|
||||
|
||||
# Don't display the banner if the course has ended
|
||||
if course_overview.end and course_overview.end < timezone.now():
|
||||
if course_overview.has_ended():
|
||||
return False, False
|
||||
|
||||
store = modulestore()
|
||||
|
||||
Reference in New Issue
Block a user