Merge pull request #6996 from edx/waqas/tnl1390-missing-discussion-blackout
Missing discussion blackout throwing exception
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user