diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py
index 0d5fbcf55b..90aefe1113 100644
--- a/common/lib/xmodule/xmodule/course_module.py
+++ b/common/lib/xmodule/xmodule/course_module.py
@@ -1,8 +1,6 @@
import time
import dateutil.parser
-from fs.errors import ResourceNotFoundError
import logging
-from path import path
from xmodule.modulestore import Location
from xmodule.seq_module import SequenceDescriptor, SequenceModule
@@ -50,77 +48,7 @@ class CourseDescriptor(SequenceDescriptor):
@property
def number(self):
return self.location.course
-
- @property
- def instructors(self):
- return self.get_about_section("instructors").split("\n")
@property
def wiki_namespace(self):
- return self.location.course
-
- def get_about_section(self, section_key):
- """
- This returns the snippet of html to be rendered on the course about page, given the key for the section.
- Valid keys:
- - overview
- - title
- - university
- - number
- - short_description
- - description
- - key_dates (includes start, end, exams, etc)
- - video
- - course_staff_short
- - course_staff_extended
- - requirements
- - syllabus
- - textbook
- - faq
- - more_info
- """
-
- # 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.
-
- # TODO: Remove number, instructors from this list
- if section_key in ['short_description', 'description', 'key_dates', 'video', 'course_staff_short', 'course_staff_extended',
- 'requirements', 'syllabus', 'textbook', 'faq', 'more_info', 'number', 'instructors', 'overview',
- 'effort', 'end_date', 'prerequisites']:
- try:
- with self.system.resources_fs.open(path("about") / section_key + ".html") as htmlFile:
- return htmlFile.read().decode('utf-8')
- except ResourceNotFoundError:
- log.warning("Missing about section {key} in course {url}".format(key=section_key, url=self.location.url()))
- return None
- elif section_key == "title":
- return self.metadata.get('display_name', self.name)
- elif section_key == "university":
- return self.location.org
- elif section_key == "number":
- 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().decode('utf-8')
- except ResourceNotFoundError:
- log.exception("Missing info section {key} in course {url}".format(key=section_key, url=self.location.url()))
- return "! Info section missing !"
-
- raise KeyError("Invalid about key " + str(section_key))
+ return self.location.course
\ No newline at end of file
diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py
index b6853ae12a..7bf3cd729f 100644
--- a/lms/djangoapps/courseware/courses.py
+++ b/lms/djangoapps/courseware/courses.py
@@ -1,10 +1,15 @@
+from fs.errors import ResourceNotFoundError
from functools import wraps
+import logging
+from path import path
+from django.conf import settings
from django.http import Http404
from xmodule.course_module import CourseDescriptor
from xmodule.modulestore.django import modulestore
+log = logging.getLogger(__name__)
def check_course(course_id, course_must_be_open=True, course_required=True):
"""
@@ -31,3 +36,81 @@ def check_course(course_id, course_must_be_open=True, course_required=True):
raise Http404("This course has not yet started.")
return course
+
+
+### These methods look like they should be on the course_module object itself, but they rely
+### on the lms. Maybe they should be added dynamically to the class?
+
+def course_static_url(course):
+ return settings.STATIC_URL + "/" + course.metadata['data_dir'] + "/"
+
+def course_image_url(course):
+ return course_static_url(course) + "images/course_image.png"
+
+def get_course_about_section(course, section_key):
+ """
+ This returns the snippet of html to be rendered on the course about page, given the key for the section.
+ Valid keys:
+ - overview
+ - title
+ - university
+ - number
+ - short_description
+ - description
+ - key_dates (includes start, end, exams, etc)
+ - video
+ - course_staff_short
+ - course_staff_extended
+ - requirements
+ - syllabus
+ - textbook
+ - faq
+ - more_info
+ """
+
+ # 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.
+
+# TODO: Remove number, instructors from this list
+ if section_key in ['short_description', 'description', 'key_dates', 'video', 'course_staff_short', 'course_staff_extended',
+ 'requirements', 'syllabus', 'textbook', 'faq', 'more_info', 'number', 'instructors', 'overview',
+ 'effort', 'end_date', 'prerequisites']:
+ try:
+ with course.system.resources_fs.open(path("about") / section_key + ".html") as htmlFile:
+ return htmlFile.read().decode('utf-8').format(COURSE_STATIC_URL = course_static_url(course) )
+ except ResourceNotFoundError:
+ log.warning("Missing about section {key} in course {url}".format(key=section_key, url=course.location.url()))
+ return None
+ elif section_key == "title":
+ return course.metadata.get('display_name', course.name)
+ elif section_key == "university":
+ return course.location.org
+ elif section_key == "number":
+ return course.number
+
+ raise KeyError("Invalid about key " + str(section_key))
+
+def get_course_info_section(course, 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 course.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile:
+ return htmlFile.read().decode('utf-8')
+ except ResourceNotFoundError:
+ log.exception("Missing info section {key} in course {url}".format(key=section_key, url=course.location.url()))
+ return "! Info section missing !"
+
+ raise KeyError("Invalid about key " + str(section_key))
+
+
\ No newline at end of file
diff --git a/lms/templates/course.html b/lms/templates/course.html
index c22ff349ea..20d052a938 100644
--- a/lms/templates/course.html
+++ b/lms/templates/course.html
@@ -1,6 +1,7 @@
<%namespace name='static' file='static_content.html'/>
<%!
from django.core.urlresolvers import reverse
+ from courseware.courses import course_image_url, get_course_about_section
%>
<%page args="course" />
@@ -9,25 +10,25 @@
-
})
+
-
${course.get_about_section('short_description')}
+
${get_course_about_section(course, 'short_description')}
diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html
index 48579d7117..caf28d920b 100644
--- a/lms/templates/dashboard.html
+++ b/lms/templates/dashboard.html
@@ -1,4 +1,7 @@
-<%! from django.core.urlresolvers import reverse %>
+<%!
+ from django.core.urlresolvers import reverse
+ from courseware.courses import course_image_url, get_course_about_section
+%>
<%inherit file="main.html" />
<%namespace name='static' file='static_content.html'/>
@@ -33,14 +36,14 @@
% for course in courses:
-
+
- ${course.get_about_section('university')}
-
+ ${get_course_about_section(course, 'university')}
+
Class Starts - 9/2/2012
diff --git a/lms/templates/info.html b/lms/templates/info.html
index d8420a098a..122a185f3a 100644
--- a/lms/templates/info.html
+++ b/lms/templates/info.html
@@ -1,5 +1,8 @@
<%inherit file="main.html" />
<%include file="course_navigation.html" args="active_page='info'" />
+<%!
+ from courseware.courses import get_course_info_section
+%>
@@ -7,17 +10,17 @@
% if user.is_authenticated():
- ${course.get_info_section('updates')}
+ ${get_course_info_section(course, 'updates')}
- ${course.get_info_section('handouts')}
+ ${get_course_info_section(course, 'handouts')}
% else:
- ${course.get_info_section('guest_updates')}
+ ${get_course_info_section(course, 'guest_updates')}
- ${course.get_info_section('guest_handouts')}
+ ${get_course_info_section(course, 'guest_handouts')}
% endif
diff --git a/lms/templates/portal/course_about.html b/lms/templates/portal/course_about.html
index cc9b60caba..739b5b5c1b 100644
--- a/lms/templates/portal/course_about.html
+++ b/lms/templates/portal/course_about.html
@@ -1,4 +1,7 @@
-<%! from django.core.urlresolvers import reverse %>
+<%!
+ from django.core.urlresolvers import reverse
+ from courseware.courses import course_image_url, get_course_about_section
+%>
<%namespace name='static' file='../static_content.html'/>
<%block name="js_extra">
@@ -11,7 +14,7 @@
- ${course.number}: ${course.get_about_section("title")}
+ ${course.number}: ${get_course_about_section(course, "title")}
@@ -27,10 +30,10 @@
- % if course.get_about_section("video"):
+ % if get_course_about_section(course, "video"):
-
})
+
@@ -50,7 +53,7 @@
- ${course.get_about_section("overview")}
+ ${get_course_about_section(course, "overview")}
@@ -76,16 +79,16 @@
Classes Start
${course.start_date_text}
## End date should come from course.xml, but this is a quick hack
- % if course.get_about_section("end_date"):
-
Classes End
${course.get_about_section("end_date")}
+ % if get_course_about_section(course, "end_date"):
+
Classes End
${get_course_about_section(course, "end_date")}
% endif
- % if course.get_about_section("effort"):
-
Estimated Effort
${course.get_about_section("effort")}
+ % if get_course_about_section(course, "effort"):
+
Estimated Effort
${get_course_about_section(course, "effort")}
% endif
- % if course.get_about_section("prerequisites"):
-
Prerequisites
${course.get_about_section("prerequisites")}
+ % if get_course_about_section(course, "prerequisites"):
+
Prerequisites
${get_course_about_section(course, "prerequisites")}
% endif
##
Course Length
15 weeks
diff --git a/lms/templates/video_modal.html b/lms/templates/video_modal.html
index 3f09857c02..a895df78d0 100644
--- a/lms/templates/video_modal.html
+++ b/lms/templates/video_modal.html
@@ -1,7 +1,10 @@
+<%!
+ from courseware.courses import get_course_about_section
+%>
<%namespace name='static' file='static_content.html'/>
- ${course.get_about_section("video")}
+ ${get_course_about_section(course, "video")}