diff --git a/lms/djangoapps/courseware/content_parser.py b/lms/djangoapps/courseware/content_parser.py
index eac163a5ce..1cd3a4be30 100644
--- a/lms/djangoapps/courseware/content_parser.py
+++ b/lms/djangoapps/courseware/content_parser.py
@@ -138,12 +138,16 @@ def user_groups(user):
# return [u.name for u in UserTestGroup.objects.raw("select * from auth_user, student_usertestgroup, student_usertestgroup_users where auth_user.id = student_usertestgroup_users.user_id and student_usertestgroup_users.usertestgroup_id = student_usertestgroup.id and auth_user.id = %s", [user.id])]
def replace_custom_tags(course, tree):
- tags = os.listdir(course.path+'/custom_tags')
- for tag in tags:
- for element in tree.iter(tag):
- element.tag = 'customtag'
- impl = etree.SubElement(element, 'impl')
- impl.text = tag
+ try:
+ tags = os.listdir(course.path+'/custom_tags')
+ for tag in tags:
+ for element in tree.iter(tag):
+ element.tag = 'customtag'
+ impl = etree.SubElement(element, 'impl')
+ impl.text = tag
+ except os.error:
+ # The directory must not exist. This is okay, as it is optional. If it is empty, git has trouble tracking it
+ pass
def course_xml_process(course, tree):
''' Do basic pre-processing of an XML tree. Assign IDs to all
diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py
index 7299dff068..2475ce72e8 100644
--- a/lms/djangoapps/courseware/courses.py
+++ b/lms/djangoapps/courseware/courses.py
@@ -44,6 +44,44 @@ class Course(namedtuple('Course', _FIELDS)):
log.exception(ex)
raise CourseInfoLoadError("Could not read course info: {0}:{1}"
.format(type(ex).__name__, ex))
+
+
+
+ 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:
+ - 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
+ """
+
+ if section_key in ['short_description', 'description', 'key_dates', 'video', 'course_staff_short', 'course_staff_extended',
+ 'requirements', 'syllabus', 'textbook', 'faq', 'more_info']:
+ try:
+ with open(self.path / "about" / section_key + ".html") as htmlFile:
+ return htmlFile.read()
+ except IOError:
+ return "! About section missing !"
+ elif section_key == "title":
+ return self.title
+ elif section_key == "university":
+ return self.institution
+ elif section_key == "number":
+ return self.number
+
+ raise KeyError("Invalid about key " + str(section_key))
def load_courses(courses_path):
"""Given a directory of courses, returns a list of Course objects. For the
diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py
index b35c4ea5cb..e3b2c48797 100644
--- a/lms/djangoapps/courseware/views.py
+++ b/lms/djangoapps/courseware/views.py
@@ -366,3 +366,23 @@ def jump_to(request, probname=None):
return index(request,
course=coursename, chapter=chapter,
section=section, position=position)
+
+
+@ensure_csrf_cookie
+def course_info(request):
+ csrf_token = csrf(request)['csrf_token']
+ # TODO: Couse should be a model
+ return render_to_response('portal/course_info.html', {'csrf': csrf_token })
+
+@ensure_csrf_cookie
+def course_info(request, course_id):
+ # This is the advertising page for a student to look at the course before signing up
+ csrf_token = csrf(request)['csrf_token']
+
+ try:
+ course = settings.COURSES_BY_ID[course_id]
+ except KeyError:
+ raise Http404("Course not found")
+
+ return render_to_response('portal/course_about.html', {'csrf': csrf_token, 'course' : course})
+
diff --git a/lms/templates/accordion.html b/lms/templates/accordion.html
index 7f67f784ad..dbeb077567 100644
--- a/lms/templates/accordion.html
+++ b/lms/templates/accordion.html
@@ -8,7 +8,7 @@
% for section in chapter['sections']:
-
-
+
${section['name']}
${section['format']} ${"due " + section['due'] if 'due' in section and section['due'] != '' else ''}
diff --git a/lms/templates/course.html b/lms/templates/course.html
index 529dcb3849..54228bc18e 100644
--- a/lms/templates/course.html
+++ b/lms/templates/course.html
@@ -1,10 +1,13 @@
<%namespace name='static' file='static_content.html'/>
+<%!
+ from django.core.urlresolvers import reverse
+%>
%for course in courses:
-
An advanced intorduction to analog circuits.
+
An advanced introduction to analog circuits.
diff --git a/lms/templates/course_info.html b/lms/templates/portal/course_about.html
similarity index 96%
rename from lms/templates/course_info.html
rename to lms/templates/portal/course_about.html
index fcfe4102a4..f088f6bd8a 100644
--- a/lms/templates/course_info.html
+++ b/lms/templates/portal/course_about.html
@@ -1,18 +1,18 @@
-<%namespace name='static' file='static_content.html'/>
+<%namespace name='static' file='../static_content.html'/>
<%block name="js_extra">
%block>
-<%inherit file="main.html" />
+<%inherit file="../main.html" />
- 18th Century History (HIS-223)
- Harvard University
+ ${course.get_about_section("title")} (${course.get_about_section("number")})
+ ${course.get_about_section("university")}
-
This course will examine the ways in which the world has grown more integrated yet more divided over the past 300 years.
+
${course.get_about_section("short_description")}
Sign up
@@ -120,7 +120,7 @@
The course will consist of 24 lectures, each lasting 50 minutes. There will be regular assignments consisting of map tests and short essays.
- Are there any prerequisites?
-
No - anyone and everyone is welcome to take this class.
+ No - anyone and everyone is welcome to take this course.
- What textbook should I buy?
Although the lectures are designed to be self-contained, we recommend (but do not require) that students refer to the book Worlds Together, Worlds Apart: A History of the World: From 1000 CE to the Present (W W Norton, 3rd edition) -- Volume II, which was written specifically for this course.
diff --git a/lms/urls.py b/lms/urls.py
index 2538609cda..f18239dc62 100644
--- a/lms/urls.py
+++ b/lms/urls.py
@@ -15,7 +15,6 @@ urlpatterns = ('',
url(r'^about$', 'student.views.about', name="about"),
url(r'^jobs$', 'student.views.jobs', name="jobs"),
url(r'^dashboard$', 'student.views.dashboard'),
- url(r'^course_info$', 'student.views.course_info'),
url(r'^change_email$', 'student.views.change_email_request'),
url(r'^email_confirm/(?P[^/]*)$', 'student.views.confirm_email_change'),
url(r'^change_name$', 'student.views.change_name_request'),
@@ -80,7 +79,8 @@ if settings.COURSEWARE_ENABLED:
url(r'^courses/(?P[^/]*)/courseware/(?P[^/]*)/(?P[^/]*)/$', 'courseware.views.index', name="courseware_section"),
url(r'^courses/(?P[^/]*)/profile$', 'courseware.views.profile', name="profile"),
url(r'^courses/(?P[^/]*)/profile/(?P[^/]*)/$', 'courseware.views.profile'),
-
+
+ url(r'^courses/(?P[^/]*)/about$', 'courseware.views.course_info', name="about_course"),
)
if settings.ENABLE_MULTICOURSE: