From 43e6bbb29fcbb61ffa9919332393d6720ca7ecbe Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Mon, 9 Jul 2012 14:16:17 -0400 Subject: [PATCH] Added info page content --- common/lib/xmodule/xmodule/course_module.py | 22 +++++++++++++++++++++ lms/templates/info.html | 8 ++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index e30280ec62..73949dcc19 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -61,3 +61,25 @@ class CourseDescriptor(SequenceDescriptor): return self.number raise KeyError("Invalid about key " + str(section_key)) + + def get_info_section(self, section_key): + """ + This returns the snippet of html to be rendered on the course info page, given the key for the section. + Valid keys: + - handouts + - guest_handouts + - updates + - guest_updates + """ + + # Many of these are stored as html files instead of some semantic markup. This can change without effecting + # this interface when we find a good format for defining so many snippets of text/html. + + if section_key in ['handouts', 'guest_handouts', 'updates', 'guest_updates']: + try: + with self.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile: + return htmlFile.read() + except IOError: + return "! About section missing !" + + raise KeyError("Invalid about key " + str(section_key)) diff --git a/lms/templates/info.html b/lms/templates/info.html index e09ec34ef2..d8420a098a 100644 --- a/lms/templates/info.html +++ b/lms/templates/info.html @@ -7,17 +7,17 @@
% if user.is_authenticated():
- ${updates} + ${course.get_info_section('updates')}
- ${handouts} + ${course.get_info_section('handouts')}
% else:
- ${guest_updates} + ${course.get_info_section('guest_updates')}
- ${guest_handouts} + ${course.get_info_section('guest_handouts')}
% endif