Don't compare None to a date when a course doesn't have an end date

This commit is contained in:
Calen Pennington
2020-06-11 09:08:55 -04:00
parent 333c9ccddf
commit 1cf46e76d0
5 changed files with 6 additions and 6 deletions

View File

@@ -84,7 +84,7 @@ class DatesTabView(RetrieveAPIView):
user_timezone = user_timezone_locale['user_timezone']
data = {
'is_archived': course.end < datetime.now(),
'is_archived': course.end and course.end < datetime.now(),
'course_date_blocks': [block for block in blocks if not isinstance(block, TodaysDate)],
'missed_deadlines': missed_deadlines,
'missed_gated_content': missed_gated_content,

View File

@@ -327,7 +327,7 @@ class CourseEndDate(DateSummary):
weeks_to_complete = get_course_run_details(self.course.id, ['weeks_to_complete']).get('weeks_to_complete')
if weeks_to_complete:
course_duration = datetime.timedelta(weeks=weeks_to_complete)
if self.course.end < (self.current_time + course_duration):
if self.course.end and self.course.end < (self.current_time + course_duration):
return self.course.end
return None

View File

@@ -1082,7 +1082,7 @@ def dates(request, course_id):
'reset_deadlines_url': reverse(RESET_COURSE_DEADLINES_NAME),
'reset_deadlines_redirect_url_base': COURSE_DATES_NAME,
'reset_deadlines_redirect_url_id_dict': {'course_id': str(course.id)},
'is_archived': course.end < datetime.now(),
'is_archived': course.end and course.end < datetime.now(),
}
return render_to_response('courseware/dates.html', context)
@@ -1681,7 +1681,7 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
'xqa_server': settings.FEATURES.get('XQA_SERVER', 'http://your_xqa_server.com'),
'missed_deadlines': missed_deadlines,
'missed_gated_content': missed_gated_content,
'is_archived': course.end < datetime.now(),
'is_archived': course.end and course.end < datetime.now(),
'web_app_course_url': reverse(COURSE_HOME_VIEW_NAME, args=[course.id]),
'on_courseware_page': True,
'verified_upgrade_link': verified_upgrade_deadline_link(request.user, course=course),

View File

@@ -794,7 +794,7 @@ class TestProgramDataExtender(ModuleStoreTestCase):
'certificate_url': None,
'course_url': reverse('course_root', args=[self.course.id]),
'enrollment_open_date': strftime_localized(DEFAULT_ENROLLMENT_START_DATE, 'SHORT_DATE'),
'is_course_ended': self.course.end < datetime.datetime.now(utc),
'is_course_ended': self.course.end and self.course.end < datetime.datetime.now(utc),
'is_enrolled': False,
'is_enrollment_open': True,
'upgrade_url': None,

View File

@@ -101,7 +101,7 @@ class CourseOutlineFragmentView(EdxFragmentView):
'on_course_outline_page': True,
'missed_deadlines': missed_deadlines,
'missed_gated_content': missed_gated_content,
'is_archived': course.end < datetime.now(),
'is_archived': course.end and course.end < datetime.now(),
}
html = render_to_string('course_experience/course-outline-fragment.html', context)