From 8e77a822fe64868ea157cd6f00e92759dd568897 Mon Sep 17 00:00:00 2001 From: Nicholas D'Alfonso Date: Tue, 17 Mar 2020 13:19:41 -0400 Subject: [PATCH] AA-73 courseware nonetype error - ensure logic for displaying reset dealines banner in courseware is behind the relative dates waffle flag, only shows if the course is self paced, and handles the situation where no sequentials exist. --- lms/djangoapps/courseware/tests/test_views.py | 5 +++-- lms/djangoapps/courseware/views/index.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 1262030044..5513d51346 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -273,8 +273,8 @@ class IndexQueryTestCase(ModuleStoreTestCase): NUM_PROBLEMS = 20 @ddt.data( - (ModuleStoreEnum.Type.mongo, 10, 174), - (ModuleStoreEnum.Type.split, 4, 172), + (ModuleStoreEnum.Type.mongo, 10, 172), + (ModuleStoreEnum.Type.split, 4, 170), ) @ddt.unpack def test_index_query_counts(self, store_type, expected_mongo_query_count, expected_mysql_query_count): @@ -2600,6 +2600,7 @@ class TestIndexView(ModuleStoreTestCase): expected_should_show_enroll_button ) + @RELATIVE_DATES_FLAG.override(active=True) def test_reset_deadlines_banner_is_present_when_viewing_courseware(self): user = UserFactory() course = CourseFactory.create(self_paced=True) diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index a0b83ac1c4..5150fc9e41 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -458,17 +458,17 @@ class CoursewareIndex(View): allow_anonymous = allow_public_access(self.course, [COURSE_VISIBILITY_PUBLIC]) display_reset_dates_banner = False - if not allow_anonymous: # pylint: disable=too-many-nested-blocks + if not allow_anonymous and RELATIVE_DATES_FLAG.is_enabled(self.course.id): # pylint: disable=too-many-nested-blocks course_overview = CourseOverview.objects.get(id=str(self.course_key)) end_date = getattr(course_overview, 'end_date') - if not end_date or timezone.now() < end_date: + if course_overview.self_paced and (not end_date or timezone.now() < end_date): if (CourseEnrollment.objects.filter( course=course_overview, user=request.user, mode=CourseMode.VERIFIED ).exists()): course_block_tree = get_course_outline_block_tree( request, str(self.course_key), request.user ) - course_sections = course_block_tree.get('children') + course_sections = course_block_tree.get('children', []) for section in course_sections: if display_reset_dates_banner: break