Implement basic ability to close off a forum for a given course such that Students can no longer post or edit, but can still view.

This commit is contained in:
David Ormsbee
2012-11-01 04:36:54 -04:00
parent e4c49f3a1e
commit 8a453e99ca
5 changed files with 34 additions and 0 deletions

View File

@@ -276,6 +276,22 @@ class CourseDescriptor(SequenceDescriptor):
more sensible framework later."""
return self.metadata.get('discussion_link', None)
@property
def forum_posts_allowed(self):
try:
blackout_periods = [(parse_time(start), parse_time(end))
for start, end
in self.metadata.get('discussion_blackouts', [])]
now = time.gmtime()
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))
raise
return True
@property
def hide_progress_tab(self):
"""TODO: same as above, intended to let internal CS50 hide the progress tab