Commit d6efd128 by Waqas Khalid

Merge pull request #6996 from edx/waqas/tnl1390-missing-discussion-blackout

Missing discussion blackout throwing exception
parents 4dd9cd2c a730f811
......@@ -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):
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment