diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index a3e4548465..350ef47f17 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -319,6 +319,10 @@ class ForumTestCase(CourseTestCase): self.course.discussion_blackouts = [(t.isoformat(), t2.isoformat()) for t, t2 in times2] self.assertFalse(self.course.forum_posts_allowed) + # test if user gives empty blackout date it should return true for forum_posts_allowed + self.course.discussion_blackouts = [[]] + self.assertTrue(self.course.forum_posts_allowed) + @ddt class CourseKeyVerificationTestCase(CourseTestCase): diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index cb91fe4b6b..405eb07980 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -1294,13 +1294,13 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): blackout_periods = [(date_proxy.from_json(start), date_proxy.from_json(end)) for start, end - in self.discussion_blackouts] + in filter(None, self.discussion_blackouts)] now = datetime.now(UTC()) for start, end in blackout_periods: if start <= now <= end: return False except: - log.exception("Error parsing discussion_blackouts for course {0}".format(self.id)) + log.exception("Error parsing discussion_blackouts %s for course %s", self.discussion_blackouts, self.id) return True