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.
This commit is contained in:
Nicholas D'Alfonso
2020-03-17 13:19:41 -04:00
parent 9535c37c79
commit 8e77a822fe
2 changed files with 6 additions and 5 deletions

View File

@@ -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)

View File

@@ -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