Call count() when you want a count.

This commit is contained in:
Alex Dusenbery
2018-05-11 14:44:44 -04:00
committed by Alex Dusenbery
parent 43d761496e
commit eb23d32dcc
2 changed files with 2 additions and 2 deletions

View File

@@ -140,7 +140,7 @@ def recalculate_course_and_subsection_grades_for_user(self, **kwargs): # pylint
course_key = CourseKey.from_string(course_key_str)
# Hotfix to address LEARNER-5123, to be removed later
visible_blocks_count = VisibleBlocks.objects.filter(course_id=course_key)
visible_blocks_count = VisibleBlocks.objects.filter(course_id=course_key).count()
if visible_blocks_count > MAX_VISIBLE_BLOCKS_ALLOWED:
message = '{} has too many VisibleBlocks to recalculate grades for {}'
raise Exception(message.format(course_key_str, user_id))

View File

@@ -486,7 +486,7 @@ class RecalculateGradesForUserTest(HasCourseWithProblemsMixin, ModuleStoreTestCa
self.set_up_course()
CourseEnrollment.enroll(self.user, self.course.id)
self.original_max_visible_blocks_allowed = tasks.MAX_VISIBLE_BLOCKS_ALLOWED
tasks.MAX_VISIBLE_BLOCKS_ALLOWED = 1
tasks.MAX_VISIBLE_BLOCKS_ALLOWED = -1
def tearDown(self):
super(RecalculateGradesForUserTest, self).tearDown()